From c5559fa07d6cd32d91d40866ab35efc749f62be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 22 Jan 2019 21:35:09 +0100 Subject: [PATCH] [photobucket] improve subalbum extraction (#117) The former implementation would produce a complete list of all subalbums for each (sub)album extraction. This would for example result in a level 2 subalbum getting "extracted" twice: once through the root-album (level 0) and once through its parent album on level 1. In the current implementation only the next level of subalbums are returned, which themselves will handle their next level in a recursive fashion. --- gallery_dl/extractor/photobucket.py | 30 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/gallery_dl/extractor/photobucket.py b/gallery_dl/extractor/photobucket.py index 8e7e99e0..c659c416 100644 --- a/gallery_dl/extractor/photobucket.py +++ b/gallery_dl/extractor/photobucket.py @@ -30,8 +30,12 @@ class PhotobucketAlbumExtractor(Extractor): }), ("http://s271.photobucket.com/user/lakerfanryan/library/", { "options": (("image-filter", "False"),), - "pattern": "http://s271.photobucket.com/user/lakerfanryan/library", - "count": ">= 22", + "pattern": pattern[0], + "count": 1, + }), + ("http://s271.photobucket.com/user/lakerfanryan/library/Basketball", { + "pattern": pattern[0], + "count": ">= 9", }), ("http://s1110.photobucket.com/user/chndrmhn100/library/" "Chandu%20is%20the%20King?sort=3&page=1", None), @@ -74,23 +78,17 @@ class PhotobucketAlbumExtractor(Extractor): params["page"] += 1 def subalbums(self): - """Yield all subalbum URLs""" + """Return all subalbum objects""" url = self.root + "/component/Albums-SubalbumList" - params = {"albumPath": self.album_path, "json": "1"} + params = { + "albumPath": self.album_path, + "fetchSubAlbumsOnly": "true", + "deferCollapsed": "true", + "json": "1", + } data = self.request(url, params=params).json() - albums = data["body"]["subAlbums"] - albums.reverse() - - while albums: - album = albums.pop() - - subs = album.pop("subAlbums") - if subs: - subs.reverse() - albums.extend(subs) - - yield album + return data["body"]["subAlbums"] class PhotobucketImageExtractor(Extractor):