Permalink
Browse files

Update `Facebook Albums` plugin.

The plugin now uses a sandbox to handle paging within a single album
correctly. To prevent duplicates, only album links to the first page are
matched.

Due to issue #52, paging support is currently broken. Albums with a
single page (i.e. less than 200 photos) should work as expected though.
  • Loading branch information...
1 parent b7bdeee commit 32eaa295d03f8ec5f124974106bd978a26910d53 @poke poke committed Apr 8, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 plugins/facebook.com_albums.json
@@ -1,8 +1,7 @@
{
- "type": "expander",
+ "type": "sandbox",
"ns": "downthemall.net",
- "prefix": "Facebook Album expander",
- "match": "^https?://(www\\.)?facebook\\.com/album\\.php\\?.*?aid=\\d+",
- "finder": "<a[^>]+href=\"(https?://(?:www\\.)?facebook\\.com/photo\\.php\\?[^\"]+)\"[^>]+>",
- "generator": "{1}"
+ "prefix": "Facebook Albums",
+ "match": "^https?://(?:www\\.)?facebook\\.com/media/set/(?:.(?!&aft|&bef))+$",
+ "resolve": "var rePhotoLink = /<a[^>]+href=\"(https?:\\/\\/(?:www\\.)?facebook\\.com\\/photo\\.php(?:[^\"]+fbid=(\\d+))?[^\"]+)\"/img;\nvar photos = [];\nfunction loadNextPage (id) {\n\twith (new Request()) {\n\t\tonload = function() {\n\t\t\tprocessText(responseText);\n\t\t};\n\t\tonerror = function() {\n\t\t\tmarkGone();\n\t\t\tfinish();\n\t\t};\n\t\topen('GET', baseURL + '&aft=' + id);\n\t\tsend();\n\t}\n}\nfunction processText (text, noloadNext) {\n\tvar lastId, m;\n\twhile ((m = rePhotoLink.exec(text)) != null) {\n\t\tphotos.push(m[1]);\n\t\tif (!!m[2]) {\n\t\t\tlastId = m[1];\n\t\t}\n\t}\n\tif (!!lastId && !noloadNext) {\n\t\tloadNextPage(lastId)\n\t}\n\telse {\n\t\tfor each (var url in photos) {\n\t\t\taddDownload(url);\n\t\t}\n\t\tsetURL(null);\n\t\tfinish();\n\t}\n}\nprocessText(responseText, responseText.indexOf('uiMorePagerPrimary') < 0);"
}

0 comments on commit 32eaa29

Please sign in to comment.