[flickr] remove constructors
This commit is contained in:
@@ -23,13 +23,10 @@ class FlickrExtractor(Extractor):
|
|||||||
request_interval = (1.0, 2.0)
|
request_interval = (1.0, 2.0)
|
||||||
request_interval_min = 0.5
|
request_interval_min = 0.5
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
Extractor.__init__(self, match)
|
|
||||||
self.item_id = match.group(1)
|
|
||||||
|
|
||||||
def _init(self):
|
def _init(self):
|
||||||
self.api = FlickrAPI(self)
|
self.api = FlickrAPI(self)
|
||||||
self.user = None
|
self.user = None
|
||||||
|
self.item_id = self.groups[0]
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
data = self.metadata()
|
data = self.metadata()
|
||||||
@@ -75,15 +72,14 @@ class FlickrImageExtractor(FlickrExtractor):
|
|||||||
r"|flic\.kr/p/([A-Za-z1-9]+))")
|
r"|flic\.kr/p/([A-Za-z1-9]+))")
|
||||||
example = "https://www.flickr.com/photos/USER/12345"
|
example = "https://www.flickr.com/photos/USER/12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
def items(self):
|
||||||
FlickrExtractor.__init__(self, match)
|
item_id, enc_id = self.groups
|
||||||
if not self.item_id:
|
if enc_id is not None:
|
||||||
alphabet = ("123456789abcdefghijkmnopqrstu"
|
alphabet = ("123456789abcdefghijkmnopqrstu"
|
||||||
"vwxyzABCDEFGHJKLMNPQRSTUVWXYZ")
|
"vwxyzABCDEFGHJKLMNPQRSTUVWXYZ")
|
||||||
self.item_id = util.bdecode(match.group(2), alphabet)
|
item_id = util.bdecode(enc_id, alphabet)
|
||||||
|
|
||||||
def items(self):
|
photo = self.api.photos_getInfo(item_id)
|
||||||
photo = self.api.photos_getInfo(self.item_id)
|
|
||||||
|
|
||||||
self.api._extract_metadata(photo)
|
self.api._extract_metadata(photo)
|
||||||
if photo["media"] == "video" and self.api.videos:
|
if photo["media"] == "video" and self.api.videos:
|
||||||
@@ -120,11 +116,8 @@ class FlickrAlbumExtractor(FlickrExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/photos/([^/?#]+)/(?:album|set)s(?:/(\d+))?"
|
pattern = BASE_PATTERN + r"/photos/([^/?#]+)/(?:album|set)s(?:/(\d+))?"
|
||||||
example = "https://www.flickr.com/photos/USER/albums/12345"
|
example = "https://www.flickr.com/photos/USER/albums/12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
FlickrExtractor.__init__(self, match)
|
|
||||||
self.album_id = match.group(2)
|
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
|
self.album_id = self.groups[1]
|
||||||
if self.album_id:
|
if self.album_id:
|
||||||
return FlickrExtractor.items(self)
|
return FlickrExtractor.items(self)
|
||||||
return self._album_items()
|
return self._album_items()
|
||||||
@@ -163,12 +156,9 @@ class FlickrGalleryExtractor(FlickrExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/photos/([^/?#]+)/galleries/(\d+)"
|
pattern = BASE_PATTERN + r"/photos/([^/?#]+)/galleries/(\d+)"
|
||||||
example = "https://www.flickr.com/photos/USER/galleries/12345/"
|
example = "https://www.flickr.com/photos/USER/galleries/12345/"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
FlickrExtractor.__init__(self, match)
|
|
||||||
self.gallery_id = match.group(2)
|
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
data = FlickrExtractor.metadata(self)
|
data = FlickrExtractor.metadata(self)
|
||||||
|
self.gallery_id = self.groups[1]
|
||||||
data["gallery"] = self.api.galleries_getInfo(self.gallery_id)
|
data["gallery"] = self.api.galleries_getInfo(self.gallery_id)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -223,13 +213,10 @@ class FlickrSearchExtractor(FlickrExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/search/?\?([^#]+)"
|
pattern = BASE_PATTERN + r"/search/?\?([^#]+)"
|
||||||
example = "https://flickr.com/search/?text=QUERY"
|
example = "https://flickr.com/search/?text=QUERY"
|
||||||
|
|
||||||
def __init__(self, match):
|
def metadata(self):
|
||||||
FlickrExtractor.__init__(self, match)
|
self.search = text.parse_query(self.groups[0])
|
||||||
self.search = text.parse_query(match.group(1))
|
|
||||||
if "text" not in self.search:
|
if "text" not in self.search:
|
||||||
self.search["text"] = ""
|
self.search["text"] = ""
|
||||||
|
|
||||||
def metadata(self):
|
|
||||||
return {"search": self.search}
|
return {"search": self.search}
|
||||||
|
|
||||||
def photos(self):
|
def photos(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user