コンテンツにスキップ

Tineye

Classes

TineyeItem

Bases: BaseSearchItem

Represents a single Tineye search result item.

A class that processes and stores individual search result data from Tineye reverse image search.

Attributes:

Name Type Description
thumbnail str

URL of the thumbnail image.

image_url str

Direct URL to the full-size image.

url str

URL of the webpage where the image was found (backlink).

domain str

Domain of the webpage.

size list[int]

Dimensions of the image as [width, height].

crawl_date str

Timestamp indicating when the image was crawled by Tineye.

Source code in PicImageSearch/model/tineye.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class TineyeItem(BaseSearchItem):
    """Represents a single Tineye search result item.

    A class that processes and stores individual search result data from Tineye reverse image search.

    Attributes:
        thumbnail (str): URL of the thumbnail image.
        image_url (str): Direct URL to the full-size image.
        url (str): URL of the webpage where the image was found (backlink).
        domain (str): Domain of the webpage.
        size (list[int]): Dimensions of the image as [width, height].
        crawl_date (str): Timestamp indicating when the image was crawled by Tineye.
    """

    def __init__(self, data: dict[str, Any], **kwargs: Any):
        """Initializes a TineyeItem with data from a search result.

        Args:
            data (dict[str, Any]): A dictionary containing the search result data.
        """
        super().__init__(data, **kwargs)

    def _parse_data(self, data: dict[str, Any], **kwargs: Any) -> None:
        """Parses the raw data for a single Tineye search result."""
        self.thumbnail: str = data["image_url"]
        self.image_url: str = data["backlinks"][0]["url"]
        self.url: str = data["backlinks"][0]["backlink"]
        self.domain: str = data["domain"]
        self.size: list[int] = [data["width"], data["height"]]
        self.crawl_date: str = data["backlinks"][0]["crawl_date"]

Functions

__init__(data, **kwargs)

Initializes a TineyeItem with data from a search result.

Parameters:

Name Type Description Default
data dict[str, Any]

A dictionary containing the search result data.

required
Source code in PicImageSearch/model/tineye.py
21
22
23
24
25
26
27
def __init__(self, data: dict[str, Any], **kwargs: Any):
    """Initializes a TineyeItem with data from a search result.

    Args:
        data (dict[str, Any]): A dictionary containing the search result data.
    """
    super().__init__(data, **kwargs)

TineyeResponse

Bases: BaseSearchResponse[TineyeItem]

Represents a complete Tineye search response.

Attributes:

Name Type Description
origin dict

The raw JSON response data from Tineye.

raw list[TineyeItem]

List of TineyeItem objects, each representing a search result.

domains dict[str, int]

A dictionary where keys are the domains where the image was found, and values are the number of matches found on that domain. Only available after the initial search.

query_hash str

Unique identifier for the search query. Used for pagination.

status_code int

HTTP status code of the response.

page_number int

Current page number.

url str

URL of the initial search results page.

Source code in PicImageSearch/model/tineye.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class TineyeResponse(BaseSearchResponse[TineyeItem]):
    """Represents a complete Tineye search response.

    Attributes:
        origin (dict): The raw JSON response data from Tineye.
        raw (list[TineyeItem]): List of TineyeItem objects, each representing a search result.
        domains (dict[str, int]):  A dictionary where keys are the domains where the image was found,
            and values are the number of matches found on that domain. Only available after the initial search.
        query_hash (str): Unique identifier for the search query. Used for pagination.
        status_code (int): HTTP status code of the response.
        page_number (int): Current page number.
        url (str): URL of the initial search results page.
    """

    def __init__(
        self,
        resp_data: dict[str, Any],
        resp_url: str,
        domains: list[DomainInfo],
        page_number: int = 1,
    ):
        """Initializes a TineyeResponse object with response data and metadata.

        Args:
            resp_data (dict[str, Any]):
            resp_url (str):
            page_number (int):
        """
        super().__init__(
            resp_data,
            resp_url,
            domains=domains,
            page_number=page_number,
        )
        self.domains = domains
        self.page_number = page_number

    def _parse_response(self, resp_data: dict[str, Any], **kwargs: Any) -> None:
        """Parses the raw JSON response from Tineye."""
        self.query_hash: str = resp_data["query_hash"]
        self.status_code: int = resp_data["status_code"]
        self.total_pages: int = resp_data["total_pages"]
        matches = resp_data["matches"]
        self.raw = [TineyeItem(i) for i in matches] if matches else []

Attributes

domains = domains instance-attribute
page_number = page_number instance-attribute

Functions

__init__(resp_data, resp_url, domains, page_number=1)

Initializes a TineyeResponse object with response data and metadata.

Parameters:

Name Type Description Default
resp_data dict[str, Any]
required
resp_url str
required
page_number int
1
Source code in PicImageSearch/model/tineye.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def __init__(
    self,
    resp_data: dict[str, Any],
    resp_url: str,
    domains: list[DomainInfo],
    page_number: int = 1,
):
    """Initializes a TineyeResponse object with response data and metadata.

    Args:
        resp_data (dict[str, Any]):
        resp_url (str):
        page_number (int):
    """
    super().__init__(
        resp_data,
        resp_url,
        domains=domains,
        page_number=page_number,
    )
    self.domains = domains
    self.page_number = page_number