From 9298dc3fccd5d290ec19fe10743a66c27df20c6b Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Wed, 15 Jan 2014 01:09:07 +0100 Subject: [PATCH] Option to disable porn. PirateBay hierarchy reshuffle. --- resources/settings.xml | 4 ++ .../site-packages/xbmctorrent/scrapers/tpb.py | 62 ++++++++----------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/resources/settings.xml b/resources/settings.xml index ce54f04..929211d 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -15,12 +15,16 @@ + + + + diff --git a/resources/site-packages/xbmctorrent/scrapers/tpb.py b/resources/site-packages/xbmctorrent/scrapers/tpb.py index 293b073..9faf2ec 100644 --- a/resources/site-packages/xbmctorrent/scrapers/tpb.py +++ b/resources/site-packages/xbmctorrent/scrapers/tpb.py @@ -11,34 +11,32 @@ HEADERS = { "Referer": BASE_URL, } + + CATEGORIES = [ - ("Audio", 100, [ - ("Music", 101), - ("Audio Books", 102), - ("Sound clips", 103), - ("FLAC", 104), - ("Other", 199), - ]), - ("Video", 200, [ - ("Movies", 201), - ("Movies DVDR", 202), - ("Music videos", 203), - ("Movie clips", 204), - ("TV shows", 205), - ("Handheld", 206), - ("HD - Movies", 207), - ("HD - TV shows", 208), - ("3D", 209), - ("Other", 299), - ]), - ("Porn", 500, [ - ("Movies", 501), - ("Movies DVDR", 502), - ("HD - Movies", 503), - ("Movie clips", 504), - ("Other", 599), - ]), + ("Movies", 201), + ("Movies DVDR", 202), + ("Music videos", 203), + ("Movie clips", 204), + ("TV shows", 205), + ("Handheld", 206), + ("HD - Movies", 207), + ("HD - TV shows", 208), + ("3D", 209), + ("Other", 299), ] + +if plugin.get_setting("porn", bool): + CATEGORIES += [ + ("Porn", 500, [ + ("Movies", 501), + ("Movies DVDR", 502), + ("HD - Movies", 503), + ("Movie clips", 504), + ("Other", 599), + ]), + ] + # Cache TTLs DEFAULT_TTL = 24 * 3600 # 24 hours @@ -48,16 +46,8 @@ @ensure_fanart @tracked def piratebay_index(): - return [ - {"label": "Search", "path": plugin.url_for("piratebay_search"), "is_playable": False}, - {"label": "Browse Torrents", "path": plugin.url_for("piratebay_browse_categories"), "is_playable": False}, - ] - + yield {"label": "Search", "path": plugin.url_for("piratebay_search")} -@plugin.route("/tpb/browse") -@ensure_fanart -@tracked -def piratebay_browse_categories(): def make_cats(root, prefix=""): for cat in root: yield { @@ -65,7 +55,7 @@ def make_cats(root, prefix=""): "path": plugin.url_for("piratebay_page", root="/browse/%d" % cat[1], page=0), } if len(cat) > 2: - for entry in make_cats(cat[2], prefix="%s " % prefix): + for entry in make_cats(cat[2], prefix="%s " % prefix): yield entry for cat in make_cats(CATEGORIES):