-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace media_url
with url
in provider scripts
#1891
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ class NyplDataIngester(ProviderDataIngester): | |
# NYPL returns a list of image objects, with the dimension encoded | ||
# in the URL's query parameter. | ||
# This list is in order from the largest image to the smallest one. | ||
image_url_dimensions = ["g", "v", "q", "w", "r"] | ||
url_dimensions = ["g", "v", "q", "w", "r"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this would be better as |
||
|
||
def __init__(self, *args, **kwargs): | ||
NYPL_API = Variable.get("API_KEY_NYPL") | ||
|
@@ -117,23 +117,21 @@ def get_record_data(self, data): | |
continue | ||
|
||
image_link = capture.get("imageLinks", {}).get("imageLink", []) | ||
image_url, filetype = NyplDataIngester._get_image_data(image_link) | ||
if not image_url: | ||
url, filetype = NyplDataIngester._get_image_data(image_link) | ||
if not url: | ||
continue | ||
|
||
foreign_landing_url = capture.get("itemLink", {}).get("$") | ||
if not foreign_landing_url: | ||
continue | ||
if not (foreign_landing_url := capture.get("itemLink", {}).get("$")): | ||
continue | ||
|
||
license_url = capture.get("rightsStatementURI", {}).get("$") | ||
if not (license_info := get_license_info(license_url)): | ||
continue | ||
|
||
image_data = { | ||
"foreign_identifier": foreign_identifier, | ||
"foreign_landing_url": foreign_landing_url, | ||
"image_url": image_url, | ||
"url": url, | ||
"license_info": license_info, | ||
"title": title, | ||
"creator": creator, | ||
|
@@ -186,9 +184,9 @@ def _get_image_data(images) -> tuple[None, None] | tuple[str, str]: | |
"description": "Cropped .jpeg (1600 pixels on the long side)" | ||
} | ||
Selects the largest image based on the image URL's `t` query parameter | ||
and image_url_dimensions. | ||
and url_dimensions. | ||
""" | ||
# Create a dict with the NyplDataIngester.image_url_dimensions as keys, | ||
# Create a dict with the NyplDataIngester.url_dimensions as keys, | ||
# and image data as value. | ||
image_types = { | ||
parse_qs(urlparse(img["$"]).query)["t"][0]: i | ||
|
@@ -200,17 +198,17 @@ def _get_image_data(images) -> tuple[None, None] | tuple[str, str]: | |
# Select the dict containing the URL for the largest image. | ||
# The image size is encoded in the URL query parameter `t`. | ||
# The list of dimensions is sorted by size of the corresponding image. | ||
for dimension in NyplDataIngester.image_url_dimensions: | ||
for dimension in NyplDataIngester.url_dimensions: | ||
preferred_image_index = image_types.get(dimension) | ||
if preferred_image_index is not None: | ||
preferred_image = images[preferred_image_index] | ||
|
||
# Removes the `download` query to get the viewable image URL | ||
image_url = preferred_image["$"].replace("&download=1", "") | ||
url = preferred_image["$"].replace("&download=1", "") | ||
filetype = NyplDataIngester._get_filetype( | ||
preferred_image["description"] | ||
) | ||
return image_url, filetype | ||
return url, filetype | ||
|
||
return None, None | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whew, this is a nice change to see!