예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    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