Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Refactor Rawpixel to use `ProviderDataIngester` (#795)
Madison Swain-Bowden4d01826907dc
diff --git a/DAGs.md b/DAGs.mdindex 62246195f..a5ae0c735 100644--- a/DAGs.md+++ b/DAGs.md@@ -86,7 +86,7 @@ The following are DAGs grouped by their primary tag:| `museum_victoria_workflow` | `@monthly` | `False` | image || `nypl_workflow` | `@monthly` | `False` | image || [`phylopic_workflow`](#phylopic_workflow) | `@daily` | `True` | image |-| `rawpixel_workflow` | `@monthly` | `False` | image |+| [`rawpixel_workflow`](#rawpixel_workflow) | `@monthly` | `False` | image || `science_museum_workflow` | `@monthly` | `False` | image || [`smithsonian_workflow`](#smithsonian_workflow) | `@weekly` | `False` | image || `smk_workflow` | `@monthly` | `False` | image |@@ -124,6 +124,7 @@ The following is documentation associated with each DAG (where available):1. [`oauth2_token_refresh`](#oauth2_token_refresh)1. [`phylopic_workflow`](#phylopic_workflow)1. [`pr_review_reminders`](#pr_review_reminders)+ 1. [`rawpixel_workflow`](#rawpixel_workflow)1. [`recreate_audio_popularity_calculation`](#recreate_audio_popularity_calculation)1. [`recreate_image_popularity_calculation`](#recreate_image_popularity_calculation)1. [`report_pending_reported_media`](#report_pending_reported_media)@@ -437,6 +438,23 @@ author of the PR to re-assign review if one of the randomly selected reviewersis unavailable for the time period during which the PR should be reviewed.+## `rawpixel_workflow`+++Content Provider: Rawpixel++ETL Process: Use the API to identify all CC-licensed images.++Output: TSV file containing the image meta-data.++Notes: Rawpixel has given Openverse beta access to their API.+ This API is undocumented, and we will need to contact Rawpixel+ directly if we run into any issues.+ The public API max results range is limited to 100,000 results,+ although the API key we've been given can circumvent this limit.+ https://www.rawpixel.com/api/v1/search?tags=$publicdomain&page=1&pagesize=100++## `recreate_audio_popularity_calculation`diff --git a/docker/local_postgres/0004_openledger_image_view.sql b/docker/local_postgres/0004_openledger_image_view.sqlindex 99a61ee56..d06d06148 100644--- a/docker/local_postgres/0004_openledger_image_view.sql+++ b/docker/local_postgres/0004_openledger_image_view.sql@@ -5,12 +5,17 @@ CREATE TABLE public.image_popularity_metrics ();+-- For more information on these values see:+-- https://github.com/cc-archive/cccatalog/issues/405#issuecomment-629233047+-- https://github.com/cc-archive/cccatalog/pull/477INSERT INTO public.image_popularity_metrics (provider, metric, percentile) VALUES('flickr', 'views', 0.85),('wikimedia', 'global_usage_count', 0.85),- ('stocksnap', 'downloads_raw', 0.85);+ ('stocksnap', 'downloads_raw', 0.85),+ ('rawpixel', 'download_count', 0.85)+;CREATE FUNCTION image_popularity_percentile(diff --git a/env.template b/env.templateindex 2511cb1c9..c8c1023fe 100644--- a/env.template+++ b/env.template@@ -28,10 +28,12 @@ AIRFLOW_VAR_API_KEY_BROOKLYN_MUSEUM=not_setAIRFLOW_VAR_API_KEY_DATA_GOV=not_setAIRFLOW_VAR_API_KEY_EUROPEANA=not_setAIRFLOW_VAR_API_KEY_FLICKR=not_set+AIRFLOW_VAR_API_KEY_FREESOUND=not_setAIRFLOW_VAR_API_KEY_JAMENDO=not_setAIRFLOW_VAR_API_KEY_NYPL=not_set+AIRFLOW_VAR_API_KEY_RAWPIXEL=not_setAIRFLOW_VAR_API_KEY_THINGIVERSE=not_set-AIRFLOW_VAR_API_KEY_FREESOUND=not_set+AIRFLOW_VAR_API_KEY_WALTERS_ART_MUSEUM=not_set########################################################################################diff --git a/openverse_catalog/dags/common/licenses/__init__.py b/openverse_catalog/dags/common/licenses/__init__.pyindex aca8b1e0f..b51f68889 100644--- a/openverse_catalog/dags/common/licenses/__init__.py+++ b/openverse_catalog/dags/common/licenses/__init__.py@@ -4,3 +4,6 @@ from .licenses import ( # noqa: F401get_license_info_from_license_pair,is_valid_license_info,)+++NO_LICENSE_FOUND = LicenseInfo(None, None, None, None)diff --git a/openverse_catalog/dags/providers/provider_api_scripts/inaturalist.py b/openverse_catalog/dags/providers/provider_api_scripts/inaturalist.pyindex aaf838b3d..97fb3b84d 100644--- a/openverse_catalog/dags/providers/provider_api_scripts/inaturalist.py+++ b/openverse_catalog/dags/providers/provider_api_scripts/inaturalist.py@@ -31,7 +31,7 @@ from airflow.providers.postgres.hooks.postgres import PostgresHookfrom airflow.providers.postgres.operators.postgres import PostgresOperatorfrom airflow.utils.task_group import TaskGroupfrom common.constants import POSTGRES_CONN_ID-from common.licenses import LicenseInfo, get_license_info+from common.licenses import NO_LICENSE_FOUND, get_license_infofrom common.loader import provider_details as provfrom providers.provider_api_scripts.provider_data_ingester import ProviderDataIngester@@ -87,7 +87,7 @@ class INaturalistDataIngester(ProviderDataIngester):return Nonelicense_url = data.get("license_url")license_info = get_license_info(license_url=license_url)- if license_info == LicenseInfo(None, None, None, None):+ if license_info == NO_LICENSE_FOUND:return Nonerecord_data = {k: data[k] for k in data.keys() if k != "license_url"}record_data["license_info"] = license_infodiff --git a/openverse_catalog/dags/providers/provider_api_scripts/rawpixel.py b/openverse_catalog/dags/providers/provider_api_scripts/rawpixel.pyindex 30a840260..4d178f447 100644--- a/openverse_catalog/dags/providers/provider_api_scripts/rawpixel.py+++ b/openverse_catalog/dags/providers/provider_api_scripts/rawpixel.py@@ -1,193 +1,282 @@+"""+Content Provider: Rawpixel++ETL Process: Use the API to identify all CC-licensed images.++Output: TSV file containing the image meta-data.++Notes: Rawpixel has given Openverse beta access to their API.+ This API is undocumented, and we will need to contact Rawpixel+ directly if we run into any issues.+ The public API max results range is limited to 100,000 results,+ although the API key we've been given can circumvent this limit.+ https://www.rawpixel.com/api/v1/search?tags=$publicdomain&page=1&pagesize=100+"""+import base64+import hmac+import htmlimport logging-from urllib.parse import parse_qs, urlparse+import re+from urllib.parse import urlencode-import requests-from common.licenses import get_license_info+from airflow.models import Variable+from common import constants+from common.licenses import NO_LICENSE_FOUND, get_license_infofrom common.loader import provider_details as prov-from common.requester import DelayedRequester-from common.storage.image import ImageStore-from requests.exceptions import JSONDecodeError+from providers.provider_api_scripts.provider_data_ingester import ProviderDataIngester-DELAY = 1.0 # time delay (in seconds)-PROVIDER = prov.RAWPIXEL_DEFAULT_PROVIDER--logging.basicConfig(- format="%(asctime)s - %(name)s - %(levelname)s: %(message)s",- level=logging.INFO,-)logger = logging.getLogger(__name__)-delayed_requester = DelayedRequester(DELAY)-image_store = ImageStore(provider=PROVIDER)--def _request_content(url, query_params=None, headers=None):- logger.info(f"Processing request: {url}")-- response = delayed_requester.get(url, params=query_params, headers=headers)- try:- if response.status_code == requests.codes.ok:- return response.json()- else:- logger.warning(- f"Unable to request URL: {url} Status code: {response.status_code}"+class RawpixelDataIngester(ProviderDataIngester):+ providers = {constants.IMAGE: prov.RAWPIXEL_DEFAULT_PROVIDER}+ api_path = "/api/v1/search"+ endpoint = f"https://www.rawpixel.com{api_path}"+ # Regex pattern for partial suffix capture+ suffix_pattern_partial = re.compile(+ r"""+ # Any text ending in free or original+ (?:free\ ?|original\ ?)?+ # Optionally "free public" or "original public"+ (?:public+ # Optionally "public domain"+ (?:\ domain+ # Optionally "original public domain CC0 photo"+ # or "free public domain CC0 image"+ (?:\ CC0\ (?:image|photo))?+ )?+ )?+ # Could end in punctuation, but the string must end with this sequence+ [.,!?]?$+ """,+ flags=re.IGNORECASE | re.VERBOSE,+ )+ # Regex pattern for full suffix capture+ suffix_pattern_full = re.compile(+ r"""+ # Capture any of these complete endings+ (?:+ Free\ public\ domain\ CC0\ (?:image|photo) |+ Digitally\ enhanced\ by\ rawpixel)- return None-- except (JSONDecodeError, TypeError, ValueError) as e:- logger.error("There was an error with the request.")- logger.info(f"{type(e).__name__}: {e}")+ # Could end in punctuation, but the string must end with this sequence+ [.,!?]?$+ """,+ flags=re.IGNORECASE | re.VERBOSE,+ )+ # Keywords which could be present in tags meaning they should be excluded+ tags_exclude_list = {+ "cc0",+ "creative commons",+ "public domain",+ }+ # Image size options+ full_size_option = "image_1300"+ # TODO: Use as part of https://github.com/WordPress/openverse-catalog/issues/817+ thumbnail_size_option = "image_600_png"++ def __init__(self, *args, **kwargs):+ super().__init__(*args, **kwargs)+ self.api_key: str = Variable.get("API_KEY_RAWPIXEL")++ def get_media_type(self, record: dict) -> str:+ return constants.IMAGE++ def _get_signature(self, query_params: dict) -> str:+ """+ URL encode the ordered parameters in a way that matches Node's+ querystring.stringify as closely as possible+ See: https://docs.python.org/3.10/library/urllib.parse.html#urllib.parse.urlencode # noqa+ and https://nodejs.org/api/querystring.html#querystringstringifyobj-sep-eq-options # noqa+ """+ # Params must be ordered for deterministic computation+ ordered_params = {k: v for k, v in sorted(query_params.items())}+ # Build parameters as a string, split out sequences since that's Node's behavior+ query = urlencode(ordered_params, doseq=True)+ # Concat onto API path, note that the scheme & fqdn are intentionally missing+ url = f"{self.api_path}?{query}"+ # Set up an HMAC using our API key and the URL as a message+ digest = hmac.digest(+ key=self.api_key.encode("utf-8"),+ msg=url.encode("utf-8"),+ digest="sha256",+ )+ # Encode it as base64+ b64 = base64.b64encode(digest)+ # Perform some character replacements, this logic was supplied explicitly by+ # Rawpixel's Node example+ signature = b64.replace(b"+", b"-").replace(b"/", b"_").replace(b"=", b"")+ # Convert back to a string+ return signature.decode("utf-8")++ def get_next_query_params(self, prev_query_params: dict | None, **kwargs) -> dict:+ if not prev_query_params:+ params = {+ "tags": "$publicdomain",+ "page": 1,+ "pagesize": self.batch_limit,+ }+ else:+ params = {**prev_query_params, "page": prev_query_params["page"] + 1}+ # Remove signature+ params.pop("s", None)+ # Inject HMAC signature after all params have been added+ return {**params, "s": self._get_signature(params)}++ def get_batch_data(self, response_json):+ if response_json and (results := response_json.get("results")):+ return resultsreturn None--def _get_image_list(page=1):- endpoint = "https://api.rawpixel.com/api/v1/search"- query_params = {"freecc0": 1, "html": 0, "page": page}- request = _request_content(endpoint, query_params=query_params)-- if request and request.get("results"):- return [request.get("total"), request.get("results")]-- else:- return [None, None]---def _get_foreign_id_url(image):- if image.get("freecc0"):- # get the image identifier- foreign_id = image.get("id", "")-- # get the landing page- foreign_url = image.get("url")-- if not foreign_url:- logger.warning(f"Landing page not detected for image ID: {foreign_id}")- return [foreign_id, foreign_url]- else:- return [None, None]---def _get_image_properties(image, foreign_url):- img_url = image.get("image_opengraph")- if img_url:- # extract the dimensions from the query params because- # the dimensions in the metadata are at times- # inconsistent with the rescaled images- query_params = urlparse(img_url)- width = parse_qs(query_params.query).get("w", [])[0]- height = parse_qs(query_params.query).get("h", [])[0]- return [img_url, width, height]- else:- logger.warning(f"Image not detected in URL: {foreign_url}")- return [None, None, None, None]---def _get_title_owner(image):- title = image.get("image_title", "")- owner = image.get("artist_names", "")- owner = owner.replace("(Source)", "").strip()- return [title, owner]---def _get_meta_data(image):- description = image.get("pinterest_description")- meta_data = {}- if description:- meta_data["description"] = description- return meta_data---def _get_tags(image):- keywords = image.get("keywords_raw")- if keywords:- keyword_list = keywords.split(",")- keyword_list = [- word.strip()- for word in keyword_list- if word.strip() not in ["cc0", "creative commons", "creative commons 0"]- ]- return keyword_list- else:+ @staticmethod+ def _get_image_url(data: dict, size_option: str) -> str | None:+ """+ Rawpixel provides a "style_uri" string which can be formatted with these values:+ 'image_24', 'image_png_24', 'image_48', 'image_png_48', 'image_100',+ 'image_png_100', 'image_150', 'image_png_150', 'image_200', 'image_png_200',+ 'image_250', 'image_png_250', 'image_300', 'image_png_300', 'image_400',+ 'image_png_400', 'image_500', 'image_png_500', 'image_600', 'image_png_600',+ 'image_700', 'image_png_700', 'image_800', 'image_png_800', 'image_900',+ 'image_png_900', 'image_1000', 'image_png_1000', 'image_1300',+ 'image_png_1300'++ The number refers to the width displayed, and a png option is provided for each+ size.+ """+ style_uri = data.get("style_uri")+ if not style_uri:+ return None+ return style_uri.format(size_option)++ @staticmethod+ def _get_image_properties(data: dict) -> tuple[None, None] | tuple[int, int]:+ width = max(data.get("width", 0), data.get("display_image_width", 0))+ height = max(data.get("height", 0), data.get("display_image_height", 0))+ if (width, height) == (0, 0):+ return None, None+ return width, height++ @staticmethod+ def _clean_text(text: str) -> str:+ # Clean whitespace+ text = text.strip()+ # First clear full patterns+ text = RawpixelDataIngester.suffix_pattern_full.sub("", text)+ # Then clear partial patterns+ text = RawpixelDataIngester.suffix_pattern_partial.sub("", text)+ # Unescape HTMl sequences+ text = html.unescape(text)+ # Clean whitespace once more+ text = text.strip()+ # Remove any trailing commas+ text = text.removesuffix(",")+ return text++ @staticmethod+ def _get_title(metadata: dict) -> str | None:+ """+ Titles come in the following form, so we clean them up a bit:+ Bull elk searches for food | Free Photo - rawpixel+ Desktop wallpaper summer beach landscape, | Free Photo - rawpixel+ Branch with a sunflower (1714–1760) | Free Photo Illustration - rawpixel+ Free public domain CC0 photo. | Free Photo - rawpixel+ Flower background. Free public domain | Free Photo - rawpixel+ """+ title: str = metadata.get("title")+ if not title:+ return None+ # Cut off the last bit about Rawpixel+ title = title.split("|", maxsplit=1)[0].strip()+ # Clean text+ title = RawpixelDataIngester._clean_text(title)+ # Remove trailing periods+ title = title.removesuffix(".")+ return title or None++ @staticmethod+ def _get_meta_data(data: dict, metadata: dict) -> dict:+ description = RawpixelDataIngester._clean_text(+ metadata.get("description_text") or ""+ )+ meta_data = {+ "description": description or None,+ "download_count": data.get("download_count"),+ }+ meta_data = {k: v for k, v in meta_data.items() if v is not None}+ return meta_data++ @staticmethod+ def _get_creator(data: dict) -> str | None:+ source = data.get("artist_names", "")+ source = source.removesuffix("(Source)").strip()+ return source or None++ @staticmethod+ def _get_tags(metadata: dict) -> list[str]:+ keywords = metadata.get("popular_keywords")+ if keywords:+ return [+ keyword+ for keyword in keywords+ if not any(+ exclude_tag in keyword+ for exclude_tag in RawpixelDataIngester.tags_exclude_list+ )+ ]return []--def _process_image_data(image):- # verify the license and extract the metadata- license_ = "cc0"- version = "1.0"-- foreign_id, foreign_url = _get_foreign_id_url(image)- if not foreign_url:+ @staticmethod+ def _get_category(metadata: dict) -> str | None:+ keywords = set(metadata.get("popular_keywords", []))+ if "public domain art" in keywords:+ return prov.ImageCategory.DIGITIZED_ARTWORK.value+ if "image" in keywords or "photo" in keywords:+ return prov.ImageCategory.PHOTOGRAPH.value+ if "clipart" in keywords:+ return prov.ImageCategory.ILLUSTRATION.valuereturn None- img_url, width, height = _get_image_properties(image, foreign_url)- if not img_url:- return None- title, owner = _get_title_owner(image)- meta_data = _get_meta_data(image)- tags = _get_tags(image)-- # TODO:How to get license_url, creator_url, source, watermarked?- license_info = get_license_info(- license_=license_,- license_version=version,- )- return image_store.add_item(- foreign_landing_url=foreign_url,- image_url=img_url,- license_info=license_info,- foreign_identifier=str(foreign_id),- width=str(width) if width else None,- height=str(height) if height else None,- title=title if title else None,- meta_data=meta_data,- raw_tags=tags,- creator=owner,- )---def _process_pages(total, result, page):- img_ctr = 0- is_valid = True-- if not total:- total = 0- is_valid = False- while (img_ctr < total) and is_valid:- logger.info(f"Processing page: {page}")+ def get_record_data(self, data: dict) -> dict | list[dict] | None:+ # verify the license and extract the metadata+ if not (foreign_id := data.get("id")):+ return None- for img in result:- total_images = _process_image_data(img)- img_ctr = total_images if total_images else img_ctr+ if not (foreign_url := data.get("url")):+ return None- page += 1- total, result = _get_image_list(page)+ if not (metadata := data.get("metadata")):+ return None- if not result:- is_valid = False+ license_info = get_license_info(metadata["licenseUrl"])+ if license_info == NO_LICENSE_FOUND:+ return None- if not total:- total = 0- is_valid = False+ if not (image_url := self._get_image_url(data, self.full_size_option)):+ return None- return img_ctr+ width, height = self._get_image_properties(data)+ return {+ "foreign_landing_url": foreign_url,+ "image_url": image_url,+ "license_info": license_info,+ "foreign_identifier": foreign_id,+ "width": width,+ "height": height,+ "title": self._get_title(metadata),+ "meta_data": self._get_meta_data(data, metadata),+ "raw_tags": self._get_tags(metadata),+ "creator": self._get_creator(data),+ "filetype": data.get("name_ext"),+ # Filesize not available via the API and wouldn't reflect final image size+ # anyway since we reference reduced-sized images+ "category": self._get_category(metadata),+ }def main():- page = 1-- logger.info("Begin: RawPixel API requests")-- total, result = _get_image_list(page)-- img_ctr = _process_pages(total, result, page=page)-- logger.info(f"Total images: {img_ctr}")-- image_store.commit()-- logger.info("Terminated!")+ ingester = RawpixelDataIngester()+ ingester.ingest_records()if __name__ == "__main__":diff --git a/openverse_catalog/dags/providers/provider_workflows.py b/openverse_catalog/dags/providers/provider_workflows.pyindex 5df0ed49c..3a119be79 100644--- a/openverse_catalog/dags/providers/provider_workflows.py+++ b/openverse_catalog/dags/providers/provider_workflows.py@@ -15,6 +15,7 @@ from providers.provider_api_scripts.museum_victoria import VictoriaDataIngesterfrom providers.provider_api_scripts.nypl import NyplDataIngesterfrom providers.provider_api_scripts.phylopic import PhylopicDataIngesterfrom providers.provider_api_scripts.provider_data_ingester import ProviderDataIngester+from providers.provider_api_scripts.rawpixel import RawpixelDataIngesterfrom providers.provider_api_scripts.science_museum import ScienceMuseumDataIngesterfrom providers.provider_api_scripts.smk import SmkDataIngesterfrom providers.provider_api_scripts.stocksnap import StockSnapDataIngester@@ -191,6 +192,7 @@ PROVIDER_WORKFLOWS = [),ProviderWorkflow(provider_script="rawpixel",+ ingestion_callable=RawpixelDataIngester,pull_timeout=timedelta(hours=12),),ProviderWorkflow(diff --git a/tests/dags/providers/provider_api_scripts/resources/rawpixel/public_domain_response.json b/tests/dags/providers/provider_api_scripts/resources/rawpixel/public_domain_response.jsonnew file mode 100644index 000000000..5040f5a10--- /dev/null+++ b/tests/dags/providers/provider_api_scripts/resources/rawpixel/public_domain_response.json@@ -0,0 +1,333 @@+{+ "blurb": "Free PNGs, stickers, photos, aesthetic backgrounds and wallpapers, vector illustrations and art. High quality premium images, PSD mockups and templates all safe for commercial use.",+ "context": {+ "context": "",+ "masterContext": ""+ },+ "cover_image": "https://img.rawpixel.com/private/static/images/website/2022-05/fl46445994624-image-ku2cmsr5.jpg?w=1200&h=1200&dpr=1&fit=clip&crop=default&fm=jpg&q=75&vib=3&con=3&usm=15&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=e66a839476b92d82bc1a8d142fcb5a16",+ "results": [+ {+ "alias": "/image/4032668/photo-image-background-nature-mountain",+ "artist_names": "National Park Service (Source)",+ "design_id": null,+ "design_type": "image",+ "display_image_height": 5515,+ "display_image_width": 8272,+ "download_count": 0,+ "editorial": false,+ "exclusive": false,+ "google_teaser": "https://img.rawpixel.com/private/static/images/website/2022-05/fl46445994624-image-ku2cmsr5.jpg?w=800&dpr=1&fit=default&crop=default&q=65&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=d910cae7cf00cad373ef82c1858b5a20",+ "height": 5515,+ "id": 4032668,+ "image_type_machine_name": "allphoto",+ "info_label": "Free U.S. Government Image",+ "isDarkPng": false,+ "isLightPng": false,+ "isPng": false,+ "isPortrait": false,+ "metadata": {+ "artist_accounts": [+ 3059155+ ],+ "artist_names": [+ "National Park Service (Source)"+ ],+ "artist_twitters": [],+ "artists": [+ {+ "account_url": "nps",+ "artist_credit": false,+ "avatar": {+ "height": 48,+ "uri": "https://assets.rawpixel.com/image_48/dXNlci9hdmF0YXIvMTYyMTkyNjU3OTk1OTIyMjRfdXNlcl9hdmF0YXIuanBn.jpg?v=1&s=_8CAU_gv5DFBUeBo1TbJF3rTJTQXHjbOjdOrpyjy-sU",+ "width": 48+ },+ "copyright": "",+ "full_name": "National Park Service (Source)",+ "twitter": "",+ "uid": 3059155+ }+ ],+ "charities": [+ {+ "description": "<p>The <a target=\"_blank\" href=\"https://www.worldwildlife.org/\">WWF's</a> (The World Wide Fund for Nature) mission is to conserve nature and reduce the most pressing threats to the diversity of life on Earth. Visit the <a target=\"_blank\" href=\"https://www.worldwildlife.org/\">WWF website</a> for ways to support them with their mission.</p>",+ "donate_link": "",+ "link": "https://www.worldwildlife.org/",+ "name": "WWF ",+ "tag": "$wwfcharity"+ }+ ],+ "compatible": null,+ "description": "Bull elk searches for food beneath the snow. Frank. Original public domain image from <a href=\"https://www.flickr.com/photos/yellowstonenps/46445994624/\" target=\"_blank\">Flickr</a>",+ "description_more": null,+ "description_text": "Bull elk searches for food beneath the snow. Frank. Original public domain image from Flickr",+ "download_options": [+ {+ "choices": [+ {+ "apiUrl": "/api/v1/image/download/4032668/jpeg?width=1200",+ "description": "1200 x 800 px | 300 dpi",+ "key": "jpeg_web",+ "label": "Small",+ "typeLabel": "JPEG"+ },+ {+ "apiUrl": "/api/v1/image/download/4032668/jpeg?width=3500",+ "description": "3500 x 2333 px | 300 dpi",+ "key": "jpeg_large",+ "label": "Large",+ "typeLabel": "JPEG"+ },+ {+ "apiUrl": "/api/v1/image/download/4032668/original",+ "description": "8272 x 5515 px | 300 dpi",+ "key": "jpeg_original",+ "label": "Original",+ "typeLabel": "JPEG"+ }+ ],+ "key": "jpeg",+ "label": "JPEG",+ "printResolutionText": ""+ }+ ],+ "fonts": {+ "fonts": [],+ "hasBundle": false+ },+ "hasIconGroup": false,+ "hasSetGroup": false,+ "hasSetfileGroup": false,+ "hasSizeGroup": false,+ "image_alt": "Bull elk searches for food beneath the snow. Frank. Original public domain image from Flickr",+ "image_type": "Image",+ "image_type_icon": [+ {+ "icon_class": "icon-galleries-circle-bg"+ }+ ],+ "info_label": "Free U.S. Government Image",+ "info_label_tags": [+ "$publicdomain",+ "$usgovernmentworks",+ "$jpegtiff"+ ],+ "isAddon": false,+ "isCC0License": true,+ "isDocxPdf": false,+ "isEditable": true,+ "isFreeLicense": false,+ "isGoogleApacheLicense": false,+ "isIcon": false,+ "isOpenSource": false,+ "isOriginalPublicDomain": false,+ "isPremiumLicense": false,+ "isPreset": false,+ "isPrint": false,+ "isPublicDomainContent": false,+ "isSafeContent": true,+ "isUSGovernmentCC0": false,+ "license": "cc0",+ "licenseSource": "rawpixel",+ "licenseUrl": "https://creativecommons.org/publicdomain/zero/1.0/",+ "pinterest_description": "Bull elk searches for food beneath the snow. Frank. Original public domain image from Flickr | free image by rawpixel.com / National Park Service (Source)",+ "popular_keywords": [+ "animal",+ "deer",+ "winter",+ "snow",+ "background",+ "sunset",+ "nature background",+ "elk",+ "national park",+ "wildlife",+ "public domain",+ "yellowstone"+ ],+ "title": "Bull elk searches for food | Free Photo - rawpixel"+ },+ "model_release": false,+ "name_ext": "jpg",+ "nodeviews": 0,+ "pd_content": false,+ "pinterestImage": "https://img.rawpixel.com/private/static/images/website/2022-05/fl46445994624-image-ku2cmsr5.jpg?w=1200&h=1200&dpr=1&fit=clip&crop=default&fm=jpg&q=75&vib=3&con=3&usm=15&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=e66a839476b92d82bc1a8d142fcb5a16",+ "property_release": false,+ "set_label": null,+ "shop_link": null,+ "showcase": false,+ "status": false,+ "style_uri": "https://images.rawpixel.com/{}/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDIyLTA1L2ZsNDY0NDU5OTQ2MjQtaW1hZ2Uta3UyY21zcjUuanBn.jpg",+ "title": null,+ "transparent": false,+ "trim_height": null,+ "trim_width": null,+ "type": "image",+ "url": "https://www.rawpixel.com/image/4032668/photo-image-background-nature-mountain",+ "width": 8272+ },+ {+ "alias": "/image/3864377/image-background-wallpaper-ocean",+ "artist_names": "",+ "design_id": null,+ "design_type": "image",+ "display_image_height": 1755,+ "display_image_width": 3120,+ "download_count": 0,+ "editorial": false,+ "exclusive": false,+ "google_teaser": "https://img.rawpixel.com/private/static/images/website/2022-05/upwk61670216-wikimedia-image-job572-1.jpg?w=800&dpr=1&fit=default&crop=default&q=65&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=2d6a659c473e7a7ece331e3867a383fe",+ "height": 1755,+ "id": 3864377,+ "image_type_machine_name": "allphoto",+ "info_label": "Free CC0 Image",+ "isDarkPng": false,+ "isLightPng": false,+ "isPng": false,+ "isPortrait": false,+ "metadata": {+ "artist_accounts": [],+ "artist_names": [],+ "artist_twitters": [],+ "artists": [],+ "charities": [+ {+ "description": "<p>Hope for Children is an international charity working towards a world where every child has a happy childhood that sets them up for a positive future.</p><p>Please consider visiting <a target=\"_blank\" href=\"https://www.hope-for-children.org/\"><strong>Hope for Children</strong></a> to <a target=\"_blank\" href=\"https://www.hope-for-children.org/donation\"><strong>donat</strong></a>e or to learn about other ways you can support them with their mission.</p>",+ "donate_link": "https://www.hope-for-children.org/donation",+ "link": "https://www.hope-for-children.org/",+ "name": "Hope for Children",+ "tag": "$hopeforchildrencharity"+ }+ ],+ "compatible": null,+ "description": "Desktop wallpaper summer beach landscape, background HD images. Original public domain image from <a href=\"https://commons.wikimedia.org/wiki/File:Bondi_Beach,_Australia_(Unsplash_9glQF-BhqUw).jpg\" target=\"_blank\">Wikimedia Commons</a>",+ "description_more": null,+ "description_text": "Desktop wallpaper summer beach landscape, background HD images. Original public domain image from Wikimedia Commons",+ "download_options": [+ {+ "choices": [+ {+ "apiUrl": "/api/v1/image/download/3864377/jpeg?width=1920",+ "description": "1920 x 1080 px | 300 dpi",+ "key": "presentation16:9sizes_0",+ "label": "Presentation",+ "typeLabel": "JPEG"+ },+ {+ "apiUrl": "/api/v1/image/download/3864377/jpeg?width=1920",+ "description": "1920 x 1080 px | 300 dpi",+ "key": "facebookeventcoversizes_0",+ "label": "Facebook Event Cover",+ "typeLabel": "JPEG"+ },+ {+ "apiUrl": "/api/v1/image/download/3864377/jpeg?width=1920",+ "description": "1920 x 1080 px | 300 dpi",+ "key": "blogbannersizes_0",+ "label": "Blog Banner",+ "typeLabel": "JPEG"+ },+ {+ "apiUrl": "/api/v1/image/download/3864377/jpeg?width=1920",+ "description": "1920 x 1080 px | 300 dpi",+ "key": "desktopwallpapersizes_0",+ "label": "HD",+ "typeLabel": "JPEG"+ },+ {+ "apiUrl": "/api/v1/image/download/3864377/original",+ "description": "3120 x 1755 px | 300 dpi",+ "key": "jpeg_original",+ "label": "Large",+ "typeLabel": "JPEG"+ }+ ],+ "key": "jpeg",+ "label": "JPEG",+ "printResolutionText": ""+ }+ ],+ "fonts": {+ "fonts": [],+ "hasBundle": false+ },+ "hasIconGroup": false,+ "hasSetGroup": false,+ "hasSetfileGroup": false,+ "hasSizeGroup": true,+ "image_alt": "Desktop wallpaper summer beach landscape, background HD images. Original public domain image from Wikimedia Commons",+ "image_type": "Image",+ "image_type_icon": [+ {+ "icon_class": "icon-galleries-circle-bg"+ }+ ],+ "info_label": "Free CC0 Image",+ "info_label_tags": [+ "$publicdomain",+ "$jpegtiff"+ ],+ "isAddon": false,+ "isCC0License": true,+ "isDocxPdf": false,+ "isEditable": true,+ "isFreeLicense": false,+ "isGoogleApacheLicense": false,+ "isIcon": false,+ "isOpenSource": false,+ "isOriginalPublicDomain": false,+ "isPremiumLicense": false,+ "isPreset": false,+ "isPrint": false,+ "isPublicDomainContent": false,+ "isSafeContent": true,+ "isUSGovernmentCC0": false,+ "license": "cc0",+ "licenseSource": "rawpixel",+ "licenseUrl": "https://creativecommons.org/publicdomain/zero/1.0/",+ "pinterest_description": "Desktop wallpaper summer beach landscape, background HD images. Original public domain image from Wikimedia Commons | free image by rawpixel.com",+ "popular_keywords": [+ "people",+ "beach",+ "public domain",+ "desktop wallpapers",+ "public domain images",+ "summer",+ "wallpaper background",+ "background",+ "australia",+ "crowd",+ "ocean",+ "wallpaper"+ ],+ "title": "Desktop wallpaper summer beach landscape, | Free Photo - rawpixel"+ },+ "model_release": false,+ "name_ext": "jpg",+ "nodeviews": 0,+ "pd_content": false,+ "pinterestImage": "https://img.rawpixel.com/private/static/images/website/2022-05/upwk61670216-wikimedia-image-job572-1.jpg?w=1200&h=1200&dpr=1&fit=clip&crop=default&fm=jpg&q=75&vib=3&con=3&usm=15&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=12a67d2a2b59d6712886af7a73eb3045",+ "property_release": false,+ "set_label": null,+ "shop_link": null,+ "showcase": false,+ "status": false,+ "style_uri": "https://images.rawpixel.com/{}/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDIyLTA1L3Vwd2s2MTY3MDIxNi13aWtpbWVkaWEtaW1hZ2Utam9iNTcyLTEuanBn.jpg",+ "title": null,+ "transparent": false,+ "trim_height": null,+ "trim_width": null,+ "type": "image",+ "url": "https://www.rawpixel.com/image/3864377/image-background-wallpaper-ocean",+ "width": 3120+ }+ ],+ "rpa": {+ "image": "$publicdomain",+ "search": ""+ },+ "spellcheck": [],+ "title": "Free Photos, PNG Stickers, Wallpapers & Backgrounds - rawpixel",+ "total": 313893,+ "uid": 0+}diff --git a/tests/dags/providers/provider_api_scripts/resources/rawpixel/total_images_but_pinterest_descr_example.json b/tests/dags/providers/provider_api_scripts/resources/rawpixel/total_images_but_pinterest_descr_example.jsondeleted file mode 100644index 4fe8cd6c1..000000000--- a/tests/dags/providers/provider_api_scripts/resources/rawpixel/total_images_but_pinterest_descr_example.json+++ /dev/null@@ -1,74 +0,0 @@-{- "blurb": "Search Free and Premium stock photos, vectors and psd mockups",- "context": {- "context": "",- "masterContext": ""- },- "cover_image": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pd44-660-ae-01_1.jpg?w=1200&h=630&fit=crop&dpr=1.5&crop=entropy&fm=pjpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=e73560c2b1465d26386c4d601c55f8df",- "html": "",- "pager": null,- "results": [- {- "art": false,- "art_class": "",- "artist_account": false,- "artist_names": "Library of Congress (Source)",- "artist_twitters": "Library%20of%20Congress%20%28Source%29",- "attributes": "",- "exclusive": false,- "field_image_flag": 7,- "field_rating": 7,- "figure_style": "\n flex-grow: 142.06185567010309;\n width: 355.1546391752577px;\n ",- "free_image": true,- "free_or_cc0": true,- "freecc0": true,- "id": 2041320,- "image": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?h=370&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=41247ba95fc1d32286852feddc9e017d",- "image_1000": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1000&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=d91ac11e622669d057fb606c9bb5acd2",- "image_1200": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1200&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=7617264f394601239f7d6b63e5334491",- "image_1400": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1400&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=af2ec5130dce7071e58c6cd37bde8b2e",- "image_1600": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1600&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=8746d2e37ef78edc2f9a812add1b683c",- "image_200": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=200&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=98b4a04fe03e7912d010326e63acadce",- "image_2000": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=2000&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=038acf2032992fb29b5c203eb8da367f",- "image_2500": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=2500&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=d7e2283a0587f7caeaffbc73ec95e7c5",- "image_400": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=400&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=6f33bfab36227436a0f9ad230fc1d64a",- "image_600": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=600&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=c9b2a7e9011906f8f241fd70b11c7138",- "image_800": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=800&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=6cf562b1819488586d8d73b898015a68",- "image_alt": "Portolan atlas of the Mediterranean Sea, western Europe, and the northwest coast of Africa: World map drawn on an oval\u2026",- "image_big": false,- "image_full": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1400&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&bg=F4F4F3&ixlib=js-2.2.1&s=5eb08bffbc526ec9a91f4af6a2e0878b",- "image_full_height": "370",- "image_full_width": "526",- "image_height": "370",- "image_opengraph": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1200&h=630&fit=crop&dpr=1.5&crop=entropy&fm=pjpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=edbf5b420430b7f118a0093686c40f93",- "image_pinterest": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1400&dpr=1&fit=default&crop=default&auto=format&fm=jpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=6af751efec1f547c865fbbc4399c4c13",- "image_retina": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?h=370&dpr=1.5&fit=default&crop=default&auto=format&fm=pjpg&q=50&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=63b82f2c07a9905140fa2532ac05365f",- "image_style": "\n padding-bottom: 70.39187227866474%;\n ",- "image_title": "World map drawn on an oval projection",- "image_type": "",- "image_type_icon": [- "<span class=\"icon-galleries-circle-bg\"></span>"- ],- "image_uri": "s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg",- "image_width": "526",- "keywords_raw": "america, antique, asia, australia, compass, continent, continental, creative commons, creative commons 0, decor, destination, earth, eastern, europe, expedition, exploration, explore, global, globe, graphic, illustration, joan oliva, journey, locate, map, mediterranean, mediterranean sea, north america, northwest coast of africa, old, oval, pen, portolan atlas, portolan atlas of the mediterranean sea western europe and the northwest coast of africa, poster, projection, public domain, ribbon, sea, south america, trip, vintage, wall art, watercolor, western, western europe, world, world map, world map drawn on an oval projection",- "logged_in": false,- "nid": 2041320,- "original_height": 2425,- "original_width": 3445,- "pinterest_share_url": "https://www.rawpixel.com/image/2041320/world-map-drawn-oval-projection",- "search_views": 165,- "search_views_month": 592,- "showcase": false,- "sort": "[708,95,1,1575623911]",- "starred": false,- "url": "https://www.rawpixel.com/image/2041320/world-map-drawn-oval-projection",- "view_mode": "photo_grid",- "webbanner": false- }- ],- "spellcheck": [],- "title": "Search Free Stock Photos, PSD Mockups & Vectors",- "total": 22215,- "uid": 0-}diff --git a/tests/dags/providers/provider_api_scripts/resources/rawpixel/total_images_example.json b/tests/dags/providers/provider_api_scripts/resources/rawpixel/total_images_example.jsondeleted file mode 100644index bdaa94d36..000000000--- a/tests/dags/providers/provider_api_scripts/resources/rawpixel/total_images_example.json+++ /dev/null@@ -1,75 +0,0 @@-{- "blurb": "Search Free and Premium stock photos, vectors and psd mockups",- "context": {- "context": "",- "masterContext": ""- },- "cover_image": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pd44-660-ae-01_1.jpg?w=1200&h=630&fit=crop&dpr=1.5&crop=entropy&fm=pjpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=e73560c2b1465d26386c4d601c55f8df",- "html": "",- "pager": null,- "results": [- {- "art": false,- "art_class": "",- "artist_account": false,- "artist_names": "Library of Congress (Source)",- "artist_twitters": "Library%20of%20Congress%20%28Source%29",- "attributes": "",- "exclusive": false,- "field_image_flag": 7,- "field_rating": 7,- "figure_style": "\n flex-grow: 142.06185567010309;\n width: 355.1546391752577px;\n ",- "free_image": true,- "free_or_cc0": true,- "freecc0": true,- "id": 2041320,- "image": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?h=370&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=41247ba95fc1d32286852feddc9e017d",- "image_1000": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1000&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=d91ac11e622669d057fb606c9bb5acd2",- "image_1200": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1200&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=7617264f394601239f7d6b63e5334491",- "image_1400": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1400&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=af2ec5130dce7071e58c6cd37bde8b2e",- "image_1600": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1600&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=8746d2e37ef78edc2f9a812add1b683c",- "image_200": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=200&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=98b4a04fe03e7912d010326e63acadce",- "image_2000": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=2000&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=038acf2032992fb29b5c203eb8da367f",- "image_2500": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=2500&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=d7e2283a0587f7caeaffbc73ec95e7c5",- "image_400": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=400&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=6f33bfab36227436a0f9ad230fc1d64a",- "image_600": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=600&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=c9b2a7e9011906f8f241fd70b11c7138",- "image_800": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=800&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=6cf562b1819488586d8d73b898015a68",- "image_alt": "Portolan atlas of the Mediterranean Sea, western Europe, and the northwest coast of Africa: World map drawn on an oval\u2026",- "image_big": false,- "image_full": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1400&dpr=1&fit=default&crop=default&auto=format&fm=pjpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&bg=F4F4F3&ixlib=js-2.2.1&s=5eb08bffbc526ec9a91f4af6a2e0878b",- "image_full_height": "370",- "image_full_width": "526",- "image_height": "370",- "image_opengraph": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1200&h=630&fit=crop&dpr=1.5&crop=entropy&fm=pjpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=edbf5b420430b7f118a0093686c40f93",- "image_pinterest": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?w=1400&dpr=1&fit=default&crop=default&auto=format&fm=jpg&q=75&vib=3&con=3&usm=15&markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=6af751efec1f547c865fbbc4399c4c13",- "image_retina": "https://img.rawpixel.com/s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg?h=370&dpr=1.5&fit=default&crop=default&auto=format&fm=pjpg&q=50&vib=3&con=3&usm=15&bg=F4F4F3&ixlib=js-2.2.1&s=63b82f2c07a9905140fa2532ac05365f",- "image_style": "\n padding-bottom: 70.39187227866474%;\n ",- "image_title": "World map drawn on an oval projection",- "image_type": "",- "image_type_icon": [- "<span class=\"icon-galleries-circle-bg\"></span>"- ],- "image_uri": "s3fs-private/rawpixel_images/website_content/pdmaps-loc-06-nam_1.jpg",- "image_width": "526",- "keywords_raw": "america, antique, asia, australia, compass, continent, continental, creative commons, creative commons 0, decor, destination, earth, eastern, europe, expedition, exploration, explore, global, globe, graphic, illustration, joan oliva, journey, locate, map, mediterranean, mediterranean sea, north america, northwest coast of africa, old, oval, pen, portolan atlas, portolan atlas of the mediterranean sea western europe and the northwest coast of africa, poster, projection, public domain, ribbon, sea, south america, trip, vintage, wall art, watercolor, western, western europe, world, world map, world map drawn on an oval projection",- "logged_in": false,- "nid": 2041320,- "original_height": 2425,- "original_width": 3445,- "pinterest_description": "Portolan atlas of the Mediterranean Sea, western Europe, and the northwest coast of Africa: World map drawn on an oval projection (ca. 1590) by Joan Oliva. Original from Library of Congress. Digitally enhanced by rawpixel. | free image by rawpixel.com / Library of Congress (Source)",- "pinterest_share_url": "https://www.rawpixel.com/image/2041320/world-map-drawn-oval-projection",- "search_views": 165,- "search_views_month": 592,- "showcase": false,- "sort": "[708,95,1,1575623911]",- "starred": false,- "url": "https://www.rawpixel.com/image/2041320/world-map-drawn-oval-projection",- "view_mode": "photo_grid",- "webbanner": false- }- ],- "spellcheck": [],- "title": "Search Free Stock Photos, PSD Mockups & Vectors",- "total": 22215,- "uid": 0-}diff --git a/tests/dags/providers/provider_api_scripts/test_rawpixel.py b/tests/dags/providers/provider_api_scripts/test_rawpixel.pyindex bb41dd53b..3e07205d9 100644--- a/tests/dags/providers/provider_api_scripts/test_rawpixel.py+++ b/tests/dags/providers/provider_api_scripts/test_rawpixel.py@@ -1,11 +1,10 @@import json-import logging-import os-from unittest.mock import patch+from pathlib import Path+import pytestfrom common.licenses import LicenseInfo-from common.storage.image import MockImageStore-from providers.provider_api_scripts import rawpixel as rwp+from common.loader.provider_details import ImageCategory+from providers.provider_api_scripts.rawpixel import RawpixelDataIngester_license_info = (@@ -15,121 +14,311 @@ _license_info = (None,)license_info = LicenseInfo(*_license_info)-rwp.image_store = MockImageStore(provider=rwp.PROVIDER, license_info=license_info)+rwp = RawpixelDataIngester()+rwp.api_key = "PREDICTABLE-KEY"-RESOURCES = os.path.join(- os.path.abspath(os.path.dirname(__file__)), "resources/rawpixel"-)--logging.basicConfig(- format="%(asctime)s - %(name)s - %(levelname)s: %(message)s",- level=logging.DEBUG,-)+RESOURCES = Path(__file__).parent.resolve() / "resources/rawpixel"def _get_resource_json(json_name):- with open(os.path.join(RESOURCES, json_name)) as f:+ with (RESOURCES / json_name).open() as f:resource_json = json.load(f)return resource_json-def test_get_image_list_giving_none():- with patch.object(rwp, "_request_content", return_value=None):- total, result = rwp._get_image_list()- assert total is None- assert result is None---def test_get_image_list_correct():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- total, result = rwp._get_image_list()- assert total == 22215- assert len(result) == 1---def test_process_pages_giving_zero():- with patch.object(rwp, "_request_content", return_value=None):- total, result = rwp._get_image_list()- img_ctr = rwp._process_pages(total, result, page=1)- assert img_ctr == 0---def test_process_image_data():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- assert rwp._process_image_data(image=result[0]) == 1---def test_get_foreign_id_url():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- foreign_id, foreign_url = rwp._get_foreign_id_url(image=result[0])- assert foreign_id == 2041320- assert (- foreign_url- == "https://www.rawpixel.com/image/2041320/world-map-drawn-oval-projection"- )---def test_get_image_properties():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- img_url, width, height = rwp._get_image_properties(- image=result[0], foreign_url=""- )- assert img_url == (- "https://img.rawpixel.com/s3fs-private/rawpixel_images/"- "website_content/pdmaps-loc-06-nam_1.jpg?w=1200&h=630&fit="- "crop&dpr=1.5&crop=entropy&fm=pjpg&q=75&vib=3&con=3&usm=15&"- "markpad=13&markalpha=90&markscale=10&markx=25&mark=rawpixel"- "-watermark.png&cs=srgb&bg=F4F4F3&ixlib=js-2.2.1&s=edbf5b4204"- "30b7f118a0093686c40f93"- )- assert width == "1200"- assert height == "630"---def test_get_title_owner():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- title, owner = rwp._get_title_owner(image=result[0])- assert title == "World map drawn on an oval projection"- assert owner == "Library of Congress"---def test_get_meta_data_given_pinterest_descr_is_present():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- meta_data = rwp._get_meta_data(image=result[0])- expected_descr_value = (- "Portolan atlas of the Mediterranean Sea, western Europe, and the"- " northwest coast of Africa: World map drawn on an oval projection"- " (ca. 1590) by Joan Oliva. Original from Library of Congress. "- "Digitally enhanced by rawpixel. | free image by rawpixel.com / "- "Library of Congress (Source)"- )- expected_meta_data = {"description": expected_descr_value}- assert meta_data == expected_meta_data---def test_get_meta_data_given_no_pinterest_descr():- r = _get_resource_json("total_images_but_pinterest_descr_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- meta_data = rwp._get_meta_data(image=result[0])- assert meta_data == {}---def test_get_tags():- r = _get_resource_json("total_images_example.json")- with patch.object(rwp, "_request_content", return_value=r):- result = rwp._get_image_list()[1]- tags = rwp._get_tags(image=result[0])- assert len(tags) == 47- assert tags[0] == "america"+ "query_params, expected",+ [+ # Empty params+ ({}, "j5VDmEme7JqzMkKAxNfjWb6EaVtIpLq4N2QnYIHZvWg"),+ # One item+ ({"foo": "bar"}, "ZenXVF0pAhfm9EzlAsvw-REsQ27nQQ5mtxmSu4upmHo"),+ # Multiple items+ (+ {"foo": "bar", "crimothy": "roberts"},+ "rSz4Ou1ZZFY57z5Ff7AHxZqwZW_PsgOsN9ksTmpbWIM",+ ),+ # Multiple items of different types+ ({"foo": "bar", "dogs": 12}, "qWEHU7OsSfSFcNsqS9OkHWMDWe_33DBxMR9ULOLrLSw"),+ (+ {"foo": "bar", "sentence": "to+be+or+not+to+be"},+ "aJccI57xaj_pH_xUcD208ZKO_lWne0c2KsjSO15qI-I",+ ),+ (+ {"foo": "bar", "sentence": "to be or not to be"},+ "jbW0P2Oi2LL-BLvRsGAydF7VGlFOvWQFMSbkJFX6LQo",+ ),+ # Multiple items with list+ (+ {"foo": "bar", "favorites": ["chocolate", "video games", "cats"]},+ "FM_kVUym-GonOgfZAeNuswEQLZas3BOOvkTXvax_mTw",+ ),+ ],+)+def test_get_signature(query_params, expected):+ actual = rwp._get_signature(query_params)+ assert actual == expected+++def test_get_next_query_params_empty():+ actual = rwp.get_next_query_params({})+ actual.pop("s")+ assert actual == {+ "tags": "$publicdomain",+ "page": 1,+ "pagesize": 100,+ }+++def test_get_next_query_params_increments_page_size():+ actual = rwp.get_next_query_params({"foo": "bar", "page": 5})+ actual.pop("s")+ assert actual == {"foo": "bar", "page": 6}+++ "data, expected",+ [+ # No data+ ({}, None),+ # Missing filter passes through+ ({"style_uri": "nothing_to_format"}, "nothing_to_format"),+ # Happy path+ (+ {"style_uri": "string_to_format: {}"},+ f"string_to_format: {rwp.full_size_option}",+ ),+ ],+)+def test_get_image_url(data, expected):+ actual = rwp._get_image_url(data, rwp.full_size_option)+ assert actual == expected+++ "data, expected",+ [+ # Empty case+ ({}, (None, None)),+ # Happy path normal fields+ ({"width": 500, "height": 600}, (500, 600)),+ # Happy path display image fields+ ({"display_image_width": 500, "display_image_height": 600}, (500, 600)),+ # One field is 0 but data is still present+ ({"width": 0, "height": 600}, (0, 600)),+ # Fields conflict so max is chosen+ ({"width": 500, "display_image_width": 700, "height": 600}, (700, 600)),+ ],+)+def test_get_image_properties(data, expected):+ actual = rwp._get_image_properties(data)+ assert actual == expected+++ "title, expected",+ [+ (+ "Bull elk searches for food | Free Photo - rawpixel",+ "Bull elk searches for food",+ ),+ (+ "Desktop wallpaper summer beach landscape, | Free Photo - rawpixel",+ "Desktop wallpaper summer beach landscape",+ ),+ (+ "Japanese autumn tree color drawing. | Free Photo - rawpixel",+ "Japanese autumn tree color drawing",+ ),+ (+ "Open hand, palm reading. Original | Free Photo Illustration - rawpixel",+ "Open hand, palm reading",+ ),+ (+ "Claude Monet's The Magpie (1868–1869) | Free Photo Illustration - rawpixel",+ "Claude Monet's The Magpie (1868–1869)",+ ),+ ("Red poppy field. Free public | Free Photo - rawpixel", "Red poppy field"),+ ("Free public domain CC0 photo. | Free Photo - rawpixel", None),+ (+ "Floral glasses. Free public domain | Free Photo - rawpixel",+ "Floral glasses",+ ),+ (+ "Claude Monet's The Cliffs at Étretat | Free Photo Illustration - rawpixel",+ "Claude Monet's The Cliffs at Étretat",+ ),+ ],+)+def test_get_title(title, expected):+ metadata = {"title": title}+ actual = rwp._get_title(metadata)+ assert actual == expected+++ "data, expected",+ [+ # Empty cases+ ({}, None),+ ({"artist_names": ""}, None),+ # Name without suffix+ ({"artist_names": "Monet"}, "Monet"),+ # Name with spaces+ ({"artist_names": " Monet "}, "Monet"),+ # Name with suffix+ ({"artist_names": "Monet (Source)"}, "Monet"),+ ],+)+def test_get_source(data, expected):+ actual = rwp._get_creator(data)+ assert actual == expected+++EXAMPLE_KEYWORDS = [+ # Digitized art+ [+ "flower",+ "vintage",+ "public domain",+ "ornament",+ "vintage illustrations",+ "floral",+ "public domain art",+ "vintage flowers",+ "illustration",+ "vintage illustration public domain",+ "victorian",+ "flowers public domain",+ ],+ # Illustration+ [+ "orange",+ "tiger",+ "tiger face",+ "bengal tiger",+ "animal illustrations",+ "public domain tiger",+ "clipart",+ "face",+ "wildlife",+ "clip art public domain",+ "animal art",+ "public domain animal",+ ],+ # Photograph+ [+ "dog",+ "public domain dog",+ "animal photos",+ "public domain",+ "public domain fashion",+ "animal",+ "photo",+ "hat dog",+ "image",+ "fashion dog",+ "beagle",+ "animals public domain",+ ],+]+++ "keywords, expected",+ zip(+ EXAMPLE_KEYWORDS,+ (+ [+ "flower",+ "vintage",+ "ornament",+ "vintage illustrations",+ "floral",+ "vintage flowers",+ "illustration",+ "victorian",+ ],+ [+ "orange",+ "tiger",+ "tiger face",+ "bengal tiger",+ "animal illustrations",+ "clipart",+ "face",+ "wildlife",+ "animal art",+ ],+ [+ "dog",+ "animal photos",+ "animal",+ "photo",+ "hat dog",+ "image",+ "fashion dog",+ "beagle",+ ],+ ),+ ),+)+def test_get_tags(keywords, expected):+ actual = rwp._get_tags({"popular_keywords": keywords})+ assert actual == expected+++ "keywords, expected",+ zip(+ [*EXAMPLE_KEYWORDS, []],+ [+ ImageCategory.DIGITIZED_ARTWORK.value,+ ImageCategory.ILLUSTRATION.value,+ ImageCategory.PHOTOGRAPH.value,+ None,+ ],+ ),+)+def test_get_category(keywords, expected):+ actual = rwp._get_category({"popular_keywords": keywords})+ assert actual == expected+++def test_get_record_data():+ data = _get_resource_json("public_domain_response.json")+ actual = rwp.get_record_data(data["results"][0])+ assert actual == {+ "category": None,+ "creator": "National Park Service",+ "filetype": "jpg",+ "foreign_identifier": 4032668,+ "foreign_landing_url": "https://www.rawpixel.com/image/4032668/photo-image-background-nature-mountain", # noqa+ "height": 5515,+ "image_url": "https://images.rawpixel.com/image_1300/cHJpdmF0ZS9sci9pbWFnZXMvd2Vic2l0ZS8yMDIyLTA1L2ZsNDY0NDU5OTQ2MjQtaW1hZ2Uta3UyY21zcjUuanBn.jpg", # noqa+ "license_info": LicenseInfo(+ license="cc0",+ version="1.0",+ url="https://creativecommons.org/publicdomain/zero/1.0/",+ raw_url="https://creativecommons.org/publicdomain/zero/1.0/",+ ),+ "meta_data": {+ "description": "Bull elk searches for food beneath the snow. Frank. Original public domain image from Flickr", # noqa+ "download_count": 0,+ },+ "raw_tags": [+ "animal",+ "deer",+ "winter",+ "snow",+ "background",+ "sunset",+ "nature background",+ "elk",+ "national park",+ "wildlife",+ "yellowstone",+ ],+ "title": "Bull elk searches for food",+ "width": 8272,+ }