예제 #1
0
class _PremiumizeDownloader(_DebridDownloadBase):
    def __init__(self, source):
        super(_PremiumizeDownloader, self).__init__(source)
        self.debrid_module = Premiumize()
        self.available_files = []

    def _fetch_available_files(self):
        if self.source["type"] in ["hoster", "cloud"]:
            return self.source
        self.available_files = self.debrid_module.direct_download(
            self.source["magnet"])["content"]
        return self.available_files

    def _get_single_item_info(self, source):
        return self.debrid_module.item_details(source["url"])

    def _resolve_file_url(self, file):
        return file[0]["link"]
예제 #2
0
class PremiumizeResolver(TorrentResolverBase):
    """
    Resolver for Premiumize
    """
    def __init__(self):
        super(PremiumizeResolver, self).__init__()
        self.debrid_module = Premiumize()
        self.transfer_class = PremiumizeTransfers()

    def _fetch_source_files(self, torrent, item_information):
        return self.debrid_module.direct_download(torrent["magnet"])["content"]

    def resolve_stream_url(self, file_info):
        """
        Convert provided source file into a link playable through debrid service
        :param file_info: Normalised information on source file
        :return: streamable link
        """
        if file_info is None:
            raise TypeError("NoneType passed to _fetch_transcode_or_standard")
        if g.get_bool_setting(
                "premiumize.transcoded") and file_info["transcode_status"] in [
                    "finished", "good_as_is"
                ]:
            return file_info["stream_link"]
        else:
            return file_info["link"]

    def _do_post_processing(self, item_information, torrent, identified_file):
        if g.get_bool_setting(
                "premiumize.addToCloud") and identified_file is not None:
            transfer = self.debrid_module.create_transfer(torrent["magnet"])
            if transfer.get("id"):
                self.transfer_class.add_premiumize_transfer(transfer["id"])
            else:
                xbmcgui.Dialog().notification(g.ADDON_NAME,
                                              g.get_language_string(30496))
                g.log(transfer, "error")