[flickr] provide human-readable 'license_name' metadata

This commit is contained in:
Mike Fährmann
2025-05-12 16:34:47 +02:00
parent cf6eff7ff7
commit bd7fcdab4c
2 changed files with 35 additions and 0 deletions

View File

@@ -262,6 +262,19 @@ class FlickrAPI(oauth.OAuth1API):
"appletv" : 1,
"iphone_wifi": 0,
}
LICENSES = {
"0": "All Rights Reserved",
"1": "Attribution-NonCommercial-ShareAlike License",
"2": "Attribution-NonCommercial License",
"3": "Attribution-NonCommercial-NoDerivs License",
"4": "Attribution License",
"5": "Attribution-ShareAlike License",
"6": "Attribution-NoDerivs License",
"7": "No known copyright restrictions",
"8": "United States Government Work",
"9": "Public Domain Dedication (CC0)",
"10": "Public Domain Mark",
}
def __init__(self, extractor):
oauth.OAuth1API.__init__(self, extractor)
@@ -526,6 +539,9 @@ class FlickrAPI(oauth.OAuth1API):
"Unable to retrieve 'contexts' data for %s (%s: %s)",
photo["id"], exc.__class__.__name__, exc)
if "license" in photo:
photo["license_name"] = self.LICENSES.get(photo["license"])
@staticmethod
def _clean_info(info):
info["title"] = info["title"]["_content"]

View File

@@ -33,6 +33,8 @@ __tests__ = (
"id" : 16089302239,
"height" : 683,
"label" : "Large",
"license" : "0",
"license_name": "All Rights Reserved",
"media" : "photo",
"pool" : list,
"set" : list,
@@ -87,6 +89,16 @@ __tests__ = (
"#category": ("", "flickr", "image"),
"#class" : flickr.FlickrImageExtractor,
"#pattern" : flickr.FlickrImageExtractor.pattern,
"id" : 26140204724,
"date": "dt:2016-05-01 10:03:33",
"user": {
"location": "diebolsheim, france",
"nsid": "23965455@N05",
"path_alias": "sgu_",
"realname": "philippe baumgart",
"username": "philippe baumgart",
},
},
{
@@ -160,6 +172,13 @@ __tests__ = (
"#url" : "https://flickr.com/search/?text=mountain",
"#category": ("", "flickr", "search"),
"#class" : flickr.FlickrSearchExtractor,
"#range" : "1-10",
"#count" : 10,
"#pattern" : r"https://live\.staticflickr\.com/\d+/.+",
"search": {
"text": "mountain",
},
},
{