def init(self, magnet_uri): self.magnet_uri = magnet_uri self.magnet_args = urlparse.parse_qs(self.magnet_uri.replace("magnet:?", "")) # I know about urlparse.urlsplit but this is faster self.magnet_display_name = "" if self.magnet_args["dn"]: self.magnet_display_name = self.magnet_args["dn"][0] self.torrent2http_options = { "magnet": magnet_uri, "dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".", "dlrate": plugin.get_setting("max_download_rate") or "0", "ulrate": plugin.get_setting("max_upload_rate") or "0", "encryption": plugin.get_setting("encryption"), } # Check for Android and FAT32 SD card issues if PLATFORM["os"] == "android" and "sdcard" in self.torrent2http_options["dlpath"].lower(): plugin.notify("Downloading to SD card is not supported (FAT32). Resetting.", delay=15000) plugin.set_setting("dlpath", "") self.torrent2http_options["dlpath"] = xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or "." # Translate smb:// url to UNC path on windows, very hacky if PLATFORM["os"] == "windows" and "smb://" in self.torrent2http_options["dlpath"].lower(): self.torrent2http_options["dlpath"] = self.torrent2http_options["dlpath"].replace("smb:", "").replace("/", "\\") 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 = [] return self
def _ensure_settings(): import os firstrun = os.path.join(plugin.addon.getAddonInfo("path"), ".firstrun") if not os.path.exists(firstrun): with open(firstrun, "w"): plugin.set_setting("base_tpb", "http://thepiratebay.org") # Properly set TPB for now plugin.notify("Please review your settings.") plugin.open_settings()
def init(self, magnet_uri): self.magnet_uri = magnet_uri self.magnet_args = urlparse.parse_qs( self.magnet_uri.replace( "magnet:?", "")) # I know about urlparse.urlsplit but this is faster self.magnet_display_name = "" if self.magnet_args["dn"]: self.magnet_display_name = self.magnet_args["dn"][0] self.torrent2http_options = { "magnet": magnet_uri, "dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".", "dlrate": plugin.get_setting("max_download_rate") or "0", "ulrate": plugin.get_setting("max_upload_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 xbmctorrent.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 = [] return self
def init(self, magnet_uri): self.magnet_uri = magnet_uri self.magnet_args = urlparse.parse_qs( self.magnet_uri.replace("magnet:?", "") ) # I know about urlparse.urlsplit but this is faster self.magnet_display_name = "" if self.magnet_args["dn"]: self.magnet_display_name = self.magnet_args["dn"][0] self.torrent2http_options = { "magnet": magnet_uri, "dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".", "dlrate": plugin.get_setting("max_download_rate") or "0", "ulrate": plugin.get_setting("max_upload_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 xbmctorrent.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 = [] return self
def index(): import os firstrun = os.path.join(plugin.addon.getAddonInfo("path"), ".firstrun") if not os.path.exists(firstrun): with open(firstrun, "w"): # This doesn't get set properly plugin.set_setting("encryption", "1") plugin.open_settings() if PLATFORM["os"] not in ["android", "linux", "windows", "darwin"]: plugin.notify("Your system \"%(os)s_%(arch)s\" is not supported." % PLATFORM, delay=15000) for module in MODULES: yield { "label": module["name"], "thumbnail": module["image"], "path": plugin.url_for(module["view"]), }
def init(self, uri, index=None): self.display_name = "" self.torrent2http_options = { "uri": uri, "dl-path": xbmc.translatePath(plugin.get_setting("dlpath") or "special://temp/" + plugin.id), "dl-rate": plugin.get_setting("max_download_rate") or "-1", "encryption": plugin.get_setting("encryption"), "file-index": index, "keep-files": plugin.get_setting("keep_files", bool), "tuned-storage": plugin.get_setting("tuned_storage", bool), } print repr(self.torrent2http_options) if "://" in self.torrent2http_options["dl-path"]: # Translate smb:// url to UNC path on windows, very hackish if PLATFORM["os"] == "windows" and self.torrent2http_options["dl-path"].lower().startswith("smb://"): self.torrent2http_options["dl-path"] = self.torrent2http_options["dl-path"].replace("smb:", "").replace("/", "\\") elif False: plugin.notify("Downloading to an unmounted network share is not supported. Resetting.", delay=15000) plugin.set_setting("dlpath", "") self.torrent2http_options["dl-path"] = "." # Check for Android and FAT32 SD card issues if PLATFORM["os"] == "android" and self.torrent2http_options["dl-path"] != ".": from xbmctorrent.utils import get_path_fs fs = get_path_fs(self.torrent2http_options["dl-path"]) 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["dl-path"] = "." self.on_playback_started = [] self.on_playback_resumed = [] self.on_playback_paused = [] self.on_playback_stopped = [] return self
def firstrun(): clear_cache() plugin.notify("Please review your settings.") plugin.set_setting("firstrun", "true") plugin.open_settings()
import re import xbmc import xbmcgui from traceback import format_exc from xbmcswift2 import actions from xbmctorrent import plugin from xbmctorrent.caching import cached_route, CACHE_DIR from xbmctorrent.scrapers import scraper from xbmctorrent.utils import ensure_fanart BASE_URL = plugin.get_setting("base_rutracker") # "https://rutracker.org/forum/" # update http -> https if BASE_URL == "http://rutracker.org/forum/": BASE_URL = "https://rutracker.org/forum/" plugin.set_setting("base_rutracker", BASE_URL) HEADERS = { 'Referer': BASE_URL, 'Accept': 'text/html, application/xml, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*', 'Accept-Language': 'ru-RU,ru;q=0.9,en;q=0.8', 'Accept-Charset': 'utf-8, *;q=0.1', 'Accept-Encoding': 'identity, *;q=0' } topic_id_parser = re.compile(r'\?t=(\d*)$', re.U) search_id_parser = re.compile(r'\?id=(.*)\&', re.U) CATEGORIES = ( ("7", u"Зарубежные фильмы", "movies", "tmdb"), ("313", u"Зарубежное кино (HD Video)", "movies", "tmdb"),