def url_get(url, params={}, headers={}, with_immunicity=True): import urllib2 from contextlib import closing from xbmctorrentV2 import plugin from xbmctorrentV2.common import USER_AGENT if params: import urllib url = "%s?%s" % (url, urllib.urlencode(params)) req = urllib2.Request(url) req.add_header("User-Agent", USER_AGENT) for k, v in headers.items(): req.add_header(k, v) if with_immunicity and plugin.get_setting("immunicity", bool): from xbmctorrentV2 import immunicity proxy = immunicity.get_proxy_for(url) if proxy: from urlparse import urlsplit parts = urlsplit(url) req.set_proxy(proxy, parts[0]) try: with closing(urllib2.urlopen(req)) as response: data = response.read() if response.headers.get("Content-Encoding", "") == "gzip": import zlib return zlib.decompressobj(16 + zlib.MAX_WBITS).decompress(data) return data except urllib2.HTTPError: return None
def track_event(*args, **kwargs): if not plugin.get_setting("ga_disable", bool) or kwargs.pop("force", False): try: from pyga.requests import Event tracker, session, visitor = get_ga() plugin.log.info("GA: Tracking event %s" % repr(args)) tracker.track_event(Event(*args, **kwargs), session, visitor) except Exception, e: import traceback plugin.log.error("GA: Call failed.") plugin.log.error(traceback.format_exc())
def track_page(path, force=False): if not plugin.get_setting("ga_disable", bool) or force: try: from pyga.requests import Page tracker, session, visitor = get_ga() plugin.log.info("GA: Tracking %s" % path) tracker.track_pageview(Page(path), session, visitor) except Exception, e: import traceback plugin.log.error("GA: Call failed.") plugin.log.error(traceback.format_exc())
def kat_index(): cats = [ {"label": "Search", "path": plugin.url_for("kat_search", sort_field="seeders", sort_order="desc")}, {"label": "Movies", "path": plugin.url_for("kat_movies")}, {"label": "Series", "path": plugin.url_for("kat_series", sort_field="seeders", sort_order="desc")}, {"label": "Anime", "path": plugin.url_for("kat_anime")}, ] if plugin.get_setting("p**n", bool): cats += [ {"label": "XXX", "path": plugin.url_for("kat_porn")}, ] return cats
def init(self, uri, subtitles): self.display_name = "" self.torrent2http_options = { "uri": uri, "dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".", "dlrate": plugin.get_setting("max_download_rate") or "0", "encryption": plugin.get_setting("encryption"), } if "://" in self.torrent2http_options["dlpath"]: # Translate smb:// url to UNC path on windows, very hackish if PLATFORM["os"] == "windows" and self.torrent2http_options["dlpath"].lower().startswith("smb://"): self.torrent2http_options["dlpath"] = self.torrent2http_options["dlpath"].replace("smb:", "").replace("/", "\\") else: plugin.notify("Downloading to an unmounted network share is not supported. Resetting.", delay=15000) plugin.set_setting("dlpath", "") self.torrent2http_options["dlpath"] = "." # Check for Android and FAT32 SD card issues if PLATFORM["os"] == "android" and self.torrent2http_options["dlpath"] != ".": from xbmctorrentV2.utils import get_path_fs fs = get_path_fs(self.torrent2http_options["dlpath"]) plugin.log.info("Download path filesytem is %s" % fs) if fs == "vfat": # FAT32 is not supported plugin.notify("Downloading to FAT32 is not supported. Resetting.", delay=15000) plugin.set_setting("dlpath", "") self.torrent2http_options["dlpath"] = "." if plugin.get_setting("keep_files", bool): plugin.log.info("Will keep file after playback.") self.torrent2http_options["keep"] = None self.on_playback_started = [] self.on_playback_resumed = [] self.on_playback_paused = [] self.on_playback_stopped = [] self.subtitles = subtitles return self
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart from xbmctorrentV2.library import library_context BASE_URL = plugin.get_setting("base_btdigg") HEADERS = { "Referer": BASE_URL, } SORT_RELEVANCE = 0 SORT_POPULARITY = 1 SORT_ADDTIME = 2 SORT_SIZE = 3 SORT_FILES = 4 @scraper("BTDigg - DHT Search Engine", "%s/logo.png" % BASE_URL) @plugin.route("/btdigg") @ensure_fanart @tracked def btdigg_index(): plugin.redirect(plugin.url_for("btdigg_search")) @plugin.route("/btdigg/search/<query>/<sort>/<page>") @library_context @ensure_fanart @tracked
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart from xbmctorrentV2.library import library_context # Temporary, will be fixed later by them IMMUNICITY_TPB_URL = "http://thepiratebay.pe" BASE_URL = "%s/" % (plugin.get_setting("immunicity", bool) and IMMUNICITY_TPB_URL or plugin.get_setting("base_tpb")) HEADERS = { "Referer": BASE_URL, } CATEGORIES = [ ("Movies", 201, [ ("in HD", 207), ("in 3D", 209), ]), ("Music videos", 203), ("TV shows", 205, [ ("in HD", 208), ]), ("Other", 299), ] if plugin.get_setting("p**n", bool): CATEGORIES += [ ("XXX", 500, [
import sys import stat import subprocess import xbmcaddon from xbmctorrentV2.common import RESOURCES_PATH from xbmctorrentV2.platform import PLATFORM from xbmctorrentV2.utils import url_get from xbmctorrentV2 import plugin ANDROID_XBMC_IDS = [ "org.xbmc.xbmc", # Stock XBMC "tv.ouya.xbmc", # OUYA XBMC "com.semperpax.spmc", # SemPer Media Center (OUYA XBMC fork) "hk.minix.xbmc", # Minix XBMC plugin.get_setting("android_app_id"), # Whatever the user sets ] def ensure_exec_perms(file_): st = os.stat(file_) os.chmod(file_, st.st_mode | stat.S_IEXEC) return file_ def get_torrent2http_binary(): binary = "torrent2http%s" % (PLATFORM["os"] == "windows" and ".exe" or "") platform = PLATFORM.copy() if platform["os"] == "darwin": # 64 bits anyway on Darwin platform["arch"] = "x64"
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart from xbmctorrentV2.library import library_context BASE_URL = "%s/" % plugin.get_setting("base_bitsnoop") HEADERS = { "Referer": BASE_URL, } # Cache TTLs DEFAULT_TTL = 24 * 3600 # 24 hours @scraper("BitSnoop - Search Engine", "%s/i/logo.png" % BASE_URL) @plugin.route("/bitsnoop") @ensure_fanart @tracked def bitsnoop_index(): plugin.redirect(plugin.url_for("bitsnoop_search")) @plugin.route("/bitsnoop/browse/<root>/<page>") @library_context @ensure_fanart @tracked def bitsnoop_page(root, page): from urlparse import urljoin from xbmctorrentV2.scrapers import rss
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart # Temporary, will be fixed later by them BASE_URL = "%s/" % plugin.get_setting("base_nyaa") HEADERS = { "Referer": BASE_URL, } CATEGORIES = [ ("Anime", "1_0", ( ("English-translated Anime", "1_37"), ("Raw Anime", "1_11"), ("Non-English-translated Anime", "1_38"), ("Anime Music Video", "1_32"), )), ("Live Action (movies)", "5_0", ( ("English-translated Live Action", "5_19"), ("Raw Live Action", "5_20"), ("Non-English-translated Live Action", "5_21"), ("Live Action Promotional Video", "5_22"), )), ] SORT_DATE = 1 SORT_SEEDERS = 2
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart BASE_URL = "%s/" % plugin.get_setting("base_extratorrent") HEADERS = { "Referer": BASE_URL, } # Cache TTLs DEFAULT_TTL = 24 * 3600 # 24 hours MOVIES_CATEGORIES = [ ("Action", "419"), ("Adventure", "28"), ("Animation", "29"), ("Asian", "30"), ("Automotive/Cars", "32"), ("Biography", "628"), ("Bollywood", "558"), ("Comedy", "33"), ("Concerts", "34"), ("Crime", "600"), ("Documentary", "35"), ("Drama", "37"), ("Dubbed Movies", "742"), ("DVD / Film Extras", "36"), ("Family", "149"), ("Fantasy", "38"),
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart BASE_URL = "%s/" % plugin.get_setting("base_kickass") HEADERS = { "Referer": BASE_URL, } MOVIES_GENRES = [ "Action", "Adult", "Adventure", "Animation", "Biography", "Comedy", "Crime", "Documentary", "Drama", "Family", "Fantasy", "Film Noir", "Game Show", "History", "Horror", "Music", "Musical", "Mystery", "News", "Reality Tv", "Romance", "Sci Fi", "Short", "Sport", "Talk Show", "Thriller", "War", "Western", ] MOVIES_CATEGORIES = [ "3D Movies", "Music videos", "Movie clips", "Handheld", "iPad", "Highres Movies", "Bollywood", "Concerts", "Dubbed Movies", "Asian", "Documentary", "Trailer", "Other Movies", ] TV_TAGS = [ "Action", "Adventure", "Animation General", "Anime", "Anthology", "Celebrities", "Children", "Children Cartoons", "Comedy", "Cooking Food", "Cooking-Food", "Crime", "Current Events", "Discovery Science", "Discovery-Science", "Drama", "Educational", "Family", "Fantasy", "History", "Horror Supernatural", "How To Do It Yourself", "How-To-Do-It-Yourself",
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route, shelf from xbmctorrentV2.utils import ensure_fanart from xbmctorrentV2.library import library_context BASE_URL = "%s/" % plugin.get_setting("base_eztv") HEADERS = { "Referer": BASE_URL, } SHOW_LIST_CACHE_TTL = 24 * 3600 # 24 hours caching # Logo found on http://thesimurg.deviantart.com/art/Logo-for-EZTV-57874544 @scraper("EZTV - Series", "http://i.imgur.com/XcH6WOg.jpg") @plugin.route("/eztv") @ensure_fanart @tracked def eztv_index(): import string for letter in ["0-9"] + list(string.ascii_uppercase): yield { "label": letter, "path": plugin.url_for("eztv_shows_by_letter", letter=letter), "is_playable": False, } @plugin.route("/eztv/shows/<letter>")
from xbmctorrentV2 import plugin from xbmctorrentV2.scrapers import scraper from xbmctorrentV2.ga import tracked from xbmctorrentV2.caching import cached_route from xbmctorrentV2.utils import ensure_fanart from xbmctorrentV2.library import library_context BASE_URL = "%s/" % plugin.get_setting("base_yify") HEADERS = { "Referer": BASE_URL, } YOUTUBE_ACTION = "plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid=%s" MOVIES_PER_PAGE = 20 GENRES = [ "Action", "Adventure", "Animation", "Biography", "Comedy", "Crime", "Documentary", "Drama", "Family", "Fantasy", "Film-Noir", "Game-Show", "History", "Horror", "Music", "Musical",