Example #1
0
 def getBufferSize(self, message):
     global max_buffer_size
     if message == "" and plugin.get_setting("download_full_file", bool) == False:
         BUFFERSIZE = float(plugin.get_setting("min_download_size"))
     else:
         BUFFERSIZE = max_buffer_size
     return BUFFERSIZE
def do_login():
    r = s.post(
        "%s/takelogin.php" % BASE_URL,
        data={"username": plugin.get_setting("z_usr"), "password": plugin.get_setting("z_pass")},
        headers=HEADERS,
    )
    if re.search(plugin.get_setting("z_usr"), r.text, re.IGNORECASE):
        return True
def do_login():
    r = s.post('%s/takelogin.php' % BASE_URL,
               data={
                   'username': plugin.get_setting('z_usr'),
                   'password': plugin.get_setting('z_pass')
               },
               headers=HEADERS)
    if re.search(plugin.get_setting('z_usr'), r.text, re.IGNORECASE):
        return True
Example #4
0
def library_add(content_type):
    import os
    import xbmc
    import xbmcgui
    from kmediatorrent.magnet import ensure_magnet, display_name
    from kmediatorrent.utils import get_show_info_from_name
    from urllib import quote_plus, unquote

    play_url = "plugin://plugin.video.kmediatorrent/play/"
    for name, entry in LIBRARY_PATHS.items():
        if entry["strContent"] == content_type:

            if not xbmcgui.Dialog().yesno(
                    "Add to %s" % name, "Add \"%s\" to %s ?" %
                (plugin.request.args_dict["label"], name), ""):
                return

            if content_type == "tvshows" and plugin.get_setting(
                    "library_tv_path") != "":
                real_path = plugin.get_setting("library_tv_path")
            elif content_type == "movies" and plugin.get_setting(
                    "library_movies_path") != "":
                real_path = plugin.get_setting("library_movies_path")
            else:
                real_path = xbmc.translatePath(entry["strPath"])

            if not os.path.exists(real_path):
                os.makedirs(real_path)
            '''
            movies_path = os.path.join(real_path, "movies")
            tv_path = os.path.join(real_path, "tv")
            if not os.path.exists(movies_path):
                os.makedirs(movies_path)
            if not os.path.exists(tv_path):
                os.makedirs(tv_path)
            '''
            uri = unquote(plugin.request.args_dict["href"].replace(
                play_url, ""))
            magnet_uri = ensure_magnet(uri)
            filename = display_name(magnet_uri)
            if not filename:
                plugin.notify("Unable to add this file. Magnet is incomplete.")
                return
            if content_type == "tvshows":
                show_info = get_show_info_from_name(filename)
                if show_info:
                    real_path = os.path.join(real_path, show_info["show"])
                    if not os.path.exists(real_path):
                        os.makedirs(real_path)

            with open(os.path.join(real_path, "%s.strm" % filename),
                      "w") as fp:
                fp.write("%s%s" % (play_url, quote_plus(magnet_uri)))
            _rescan_library(entry["strPath"])
            plugin.notify("Added to %s." % name)
            break
    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",
            "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 kmediatorrent.utils import get_path_fs
            fs = get_path_fs(self.torrent2http_options["dlpath"])
            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
def library_add(content_type):
    import os
    import xbmc
    import xbmcgui
    from kmediatorrent.magnet import ensure_magnet, display_name
    from kmediatorrent.utils import get_show_info_from_name
    from urllib import quote_plus, unquote

    play_url = "plugin://plugin.video.kmediatorrent/play/"
    for name, entry in LIBRARY_PATHS.items():
        if entry["strContent"] == content_type:

            if not xbmcgui.Dialog().yesno(
                "Add to %s" % name, 'Add "%s" to %s ?' % (plugin.request.args_dict["label"], name), ""
            ):
                return

            if content_type == "tvshows" and plugin.get_setting("library_tv_path") != "":
                real_path = plugin.get_setting("library_tv_path")
            elif content_type == "movies" and plugin.get_setting("library_movies_path") != "":
                real_path = plugin.get_setting("library_movies_path")
            else:
                real_path = xbmc.translatePath(entry["strPath"])

            if not os.path.exists(real_path):
                os.makedirs(real_path)
            """
            movies_path = os.path.join(real_path, "movies")
            tv_path = os.path.join(real_path, "tv")
            if not os.path.exists(movies_path):
                os.makedirs(movies_path)
            if not os.path.exists(tv_path):
                os.makedirs(tv_path)
            """
            uri = unquote(plugin.request.args_dict["href"].replace(play_url, ""))
            magnet_uri = ensure_magnet(uri)
            filename = display_name(magnet_uri)
            if not filename:
                plugin.notify("Unable to add this file. Magnet is incomplete.")
                return
            if content_type == "tvshows":
                show_info = get_show_info_from_name(filename)
                if show_info:
                    real_path = os.path.join(real_path, show_info["show"])
                    if not os.path.exists(real_path):
                        os.makedirs(real_path)

            with open(os.path.join(real_path, "%s.strm" % filename), "w") as fp:
                fp.write("%s%s" % (play_url, quote_plus(magnet_uri)))
            _rescan_library(entry["strPath"])
            plugin.notify("Added to %s." % name)
            break
def url_get(url, params={}, headers={}, with_immunicity=True):
    import urllib2
    from contextlib import closing
    from kmediatorrent import plugin
    from kmediatorrent.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 kmediatorrent 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
Example #8
0
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
Example #9
0
def url_get(url, params={}, headers={}, with_immunicity=True):
    import urllib2
    from contextlib import closing
    from kmediatorrent import plugin
    from kmediatorrent.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 kmediatorrent 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
Example #10
0
 def getExtensionMessage(self, extension):
     dlpath = plugin.get_setting("dlpath")
     if dlpath == "":
         dlpath = torrent2http.get_binary_dir() #default download path
     message = ""
     fileCanStream = False
     filename = (os.path.join(dlpath, self.display_name)).encode("utf-8")
     isFile = os.path.isfile(filename)
     if isFile:
         fileCanStream = processor.process(filename, filename);
         if (extension == ".mp4" or extension == ".m4v") and isFile and fileCanStream:
             message = ""                   
         elif (extension == ".mp4" or extension == ".m4v") and isFile and fileCanStream == False:
             message = "File can not fast start. The whole file must download."
         elif (extension == ".avi" or extension == ".AVI") and isFile and plugin.get_setting("download_full_avi", bool) == True:
             message = "File can not fast start. The whole file must download."
     return message
Example #11
0
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())
Example #12
0
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",
            "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 kmediatorrent.utils import get_path_fs
            fs = get_path_fs(self.torrent2http_options["dlpath"])
            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 kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route, shelf
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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


@scraper("%s" % str(plugin.get_setting("eztv_label")),
         "%s" % str(plugin.get_setting("eztv_picture")))
@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>")
@cached_route(ttl=SHOW_LIST_CACHE_TTL, content_type="tvshows")
Example #16
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.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",
Example #17
0
import os, re
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.library import library_context

# Get addon params
BASE_URL = plugin.get_setting("base_cpb")
SCRAPPER_LABEL = plugin.get_setting("cpb_label")
SCRAPPER_PICTURE = plugin.get_setting("cpb_picture")

# Set a default picture
if SCRAPPER_PICTURE == '':
    SCRAPPER_PICTURE = "%s/_template/reloaded/_styles/_images/logo.png" % BASE_URL

HEADERS = {
    "Referer": BASE_URL,
}

SORT_DATE="trie-date"
SORT_NOM="trie-nom"
SORT_TELECHARGEMENT="trie-telechargement"
SORT_SEEDS="trie-seeds"
SORT_LEECHS="trie-leechs"
SORT_CATEGORIE="trie-categorie"

SORT_DIRECTION_ASC="-a"
SORT_DIRECTION_DESC="-d"
Example #18
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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",
import stat
import time
import subprocess
import xbmcaddon
from kmediatorrent.common import RESOURCES_PATH
from kmediatorrent.platform import PLATFORM
from kmediatorrent.utils import url_get
from kmediatorrent import plugin

ANDROID_XBMC_IDS = [
    "org.xbmc.kodi",  # Stock XBMC Kodi
    "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_binary_dir():
    platform = PLATFORM.copy()
    if platform["os"] == "darwin":  # 64 bits anyway on Darwin
        platform["arch"] = "x64"
    elif platform["os"] == "windows":  # 32 bits anyway on Windows
        platform["arch"] = "x86"
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route, shelf
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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

@scraper("%s"%str(plugin.get_setting("eztv_label")), "%s"%str(plugin.get_setting("eztv_picture")))
@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>")
@cached_route(ttl=SHOW_LIST_CACHE_TTL, content_type="tvshows")
@ensure_fanart
Example #21
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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 kmediatorrent.magnet as magnet
import requests
import re
from bs4 import BeautifulSoup
from bs4 import SoupStrainer

CUSTOM_TRACKERS = [
    "http://tracker.zelka.org/announce.php?passkey=28878cff72aef4b3d08765455c64c1bb",
    "http://flashtorrents.org/announce.php",
    "http://94.228.192.98/announce",
    "udp://9.rarbg.com:2710/announce",
]
magnet.PUBLIC_TRACKERS += CUSTOM_TRACKERS

BASE_URL = plugin.get_setting("base_zelka")
categories = [
    {"cat_ids": "5", "cat_name": u"Hd Movies"},
    {"cat_ids": "31", "cat_name": u"Science Movies"},
    {"cat_ids": "28", "cat_name": u"Russian Movies"},
    {"cat_ids": "35", "cat_name": u"x264 Movies"},
    {"cat_ids": "24", "cat_name": u"Bg Movies"},
    {"cat_ids": "33", "cat_name": u"Hd Series"},
    {"cat_ids": "7", "cat_name": u"Series"},
    {"cat_ids": "43", "cat_name": u"Hd Sport"},
]

categories_xxx = [{"cat_ids": "9", "cat_name": u"XXX"}, {"cat_ids": "49", "cat_name": u"Hd XXX"}]

fnd = {"search": "", "page": "0", "cat": "", "incldead": "0", "in": "name"}
    def loop(self):
        from kmediatorrent.utils import SafeDialogProgress

        has_resolved = False

        plugin.log.info("Starting torrent2http...")
        with closing(torrent2http.start(**self.torrent2http_options)) as t2h_instance:
            t2h = lambda cmd: url_get_json("http://%s/%s" % (t2h_instance.bind_address, cmd), with_immunicity=False)
            if not self._wait_t2h_startup(t2h):
                return

            plugin.log.info("Opening download dialog...")
            with closing(SafeDialogProgress(delay_create=0)) as dialog:
                dialog.create(plugin.name)

                plugin.log.info("Waiting for file resolution...")
                
                while not has_resolved:
                    if xbmc.abortRequested or dialog.iscanceled():
                        return

                    status = t2h("status")
                    self.display_name = status["name"]
                    global buffer_percentage
                    global extension_message
                    global max_buffer_size
                    extension = self.getFileExtension(self.display_name)
                    BUFFERSIZE = self.getBufferSize(extension_message)
                    
                    if status["state"] >= 0 and buffer_percentage < 100 and BUFFERSIZE != max_buffer_size and extension_message == "":
                        dialog.update(int(buffer_percentage), *self._get_status_lines(status, "")) #buffering
                    elif status["state"] >= 0 and buffer_percentage >= 100 or BUFFERSIZE == max_buffer_size or extension_message != "": 
                        dialog.update(int(status["progress"] * 100), *self._get_status_lines(status, extension_message))#done buffering

                    if status["state"] >= 3 and not has_resolved: # Downloading?
                        files = t2h("ls")["files"]
                        progress = float(t2h("status")["progress"])
                        biggest_file = sorted(files, key=lambda x: x["size"])[-1]
                        biggest_file["name"] = biggest_file["name"].encode("utf-8")

                        # Estimate the video size using the biggest file size
                        # and the progress (progress is: <pcnt downloaded> / 100.0)
                        bytes_complete = float(biggest_file["size"]) * progress
                        mb_complete = bytes_complete / 1024.0 / 1024.0
                        buffer_percentage = (mb_complete / float(plugin.get_setting("min_download_size"))) * 100
                        if buffer_percentage >= 100 and BUFFERSIZE != max_buffer_size:
                            extension_message = self.getExtensionMessage(extension)
                        if extension_message == "File can not fast start. The whole file must download.":
                            BUFFERSIZE = max_buffer_size
                            
                        if mb_complete > BUFFERSIZE or bytes_complete >= biggest_file["size"]:
                            extension_message = ""
                            dialog.update(int(status["progress"] * 100), *self._get_status_lines(status, extension_message))
                            plugin.log.info("Resolving to http://%s/files/%s" % (t2h_instance.bind_address, biggest_file["name"]))
                            has_resolved = True
                            item = {
                                "path": "http://%s/files/%s" % (t2h_instance.bind_address, urllib.quote(biggest_file["name"])),
                            }
                            if not xbmc.getInfoLabel("ListItem.Title"):
                                item["label"] = self.display_name
                            plugin.set_resolved_url(item)
                            break
                    xbmc.sleep(TORRENT2HTTP_POLL)

            # We are now playing
            plugin.log.info("Now playing torrent...")
            last_playing_event = 0
            with closing(OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay:
                with nested(self.attach(overlay.show, self.on_playback_paused),
                            self.attach(overlay.hide, self.on_playback_resumed, self.on_playback_stopped)):
                    while not xbmc.abortRequested and self.isPlaying():
                        overlay.text = "\n".join(self._get_status_lines(t2h("status"), extension_message))
                        now = time.time()
                        if (now - last_playing_event) > PLAYING_EVENT_INTERVAL:
                            track_event("video", "playing", self.display_name)
                            last_playing_event = now
                        xbmc.sleep(TORRENT2HTTP_POLL)

        plugin.log.info("Closing Torrent player.")
Example #24
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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("%s" % plugin.get_setting("bitsnoop_label"),
         "%s" % plugin.get_setting("bitsnoop_picture"))
@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 kmediatorrent.scrapers import rss
import socket
from kmediatorrent import plugin, magnet, scrapers
from kmediatorrent.ga import tracked
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.platform import PLATFORM

scrapers = ["eztv","yify","tpb","kickass","bitsnoop","btdigg","extratorrent","nyaa","zelka"]
scrapersToDisplay = []
for scraper in scrapers:
    if plugin.get_setting("display_%s"%scraper, bool):
        scrapersToDisplay.append("%s"%scraper)

from kmediatorrent.scrapers import \
    MODULES
for scraper in scrapersToDisplay:
    __import__("kmediatorrent.scrapers", fromlist=[scraper])

@plugin.route("/")
@ensure_fanart
@tracked(force=True)
def index():
    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"]),
        }
Example #26
0
import socket
from kmediatorrent import plugin, magnet, scrapers
from kmediatorrent.ga import tracked
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.platform import PLATFORM

scrapers = [
    "eztv", "yify", "tpb", "kickass", "bitsnoop", "btdigg", "extratorrent",
    "nyaa", "zelka", "cpb"
]
scrapersToDisplay = []
for scraper in scrapers:
    if plugin.get_setting("display_%s" % scraper, bool):
        scrapersToDisplay.append("%s" % scraper)

from kmediatorrent.scrapers import \
    MODULES
for scraper in scrapersToDisplay:
    __import__("kmediatorrent.scrapers", fromlist=[scraper])


@plugin.route("/")
@ensure_fanart
@tracked(force=True)
def index():
    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:
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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("%s"%plugin.get_setting("btdigg_label"), "%s"%plugin.get_setting("btdigg_picture"))
@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
Example #28
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.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 kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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",
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.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",
from kmediatorrent.library import library_context

import kmediatorrent.magnet as magnet
import requests
import re
from bs4 import BeautifulSoup
from bs4 import SoupStrainer

CUSTOM_TRACKERS = [
    "http://tracker.zelka.org/announce.php?passkey=28878cff72aef4b3d08765455c64c1bb",
    "http://flashtorrents.org/announce.php", "http://94.228.192.98/announce",
    "udp://9.rarbg.com:2710/announce"
]
magnet.PUBLIC_TRACKERS += CUSTOM_TRACKERS

BASE_URL = plugin.get_setting("base_zelka")
categories = [{
    'cat_ids': '5',
    'cat_name': u'Hd Movies'
}, {
    'cat_ids': '31',
    'cat_name': u'Science Movies'
}, {
    'cat_ids': '28',
    'cat_name': u'Russian Movies'
}, {
    'cat_ids': '35',
    'cat_name': u'x264 Movies'
}, {
    'cat_ids': '24',
    'cat_name': u'Bg Movies'
    def loop(self):
        from kmediatorrent.utils import SafeDialogProgress

        has_resolved = False

        plugin.log.info("Starting torrent2http...")
        with closing(torrent2http.start(
                **self.torrent2http_options)) as t2h_instance:
            t2h = lambda cmd: url_get_json("http://%s/%s" %
                                           (t2h_instance.bind_address, cmd),
                                           with_immunicity=False)
            if not self._wait_t2h_startup(t2h):
                return

            plugin.log.info("Opening download dialog...")
            with closing(SafeDialogProgress(delay_create=0)) as dialog:
                dialog.create(plugin.name)

                plugin.log.info("Waiting for file resolution...")

                while not has_resolved:
                    if xbmc.abortRequested or dialog.iscanceled():
                        return

                    status = t2h("status")
                    self.display_name = status["name"]
                    global buffer_percentage
                    global extension_message
                    global max_buffer_size
                    extension = self.getFileExtension(self.display_name)
                    BUFFERSIZE = self.getBufferSize(extension_message)

                    if status[
                            "state"] >= 0 and buffer_percentage < 100 and BUFFERSIZE != max_buffer_size and extension_message == "":
                        dialog.update(int(buffer_percentage),
                                      *self._get_status_lines(status,
                                                              ""))  #buffering
                    elif status[
                            "state"] >= 0 and buffer_percentage >= 100 or BUFFERSIZE == max_buffer_size or extension_message != "":
                        dialog.update(int(status["progress"] * 100),
                                      *self._get_status_lines(
                                          status,
                                          extension_message))  #done buffering

                    if status[
                            "state"] >= 3 and not has_resolved:  # Downloading?
                        files = t2h("ls")["files"]
                        progress = float(t2h("status")["progress"])
                        biggest_file = sorted(files,
                                              key=lambda x: x["size"])[-1]
                        biggest_file["name"] = biggest_file["name"].encode(
                            "utf-8")

                        # Estimate the video size using the biggest file size
                        # and the progress (progress is: <pcnt downloaded> / 100.0)
                        bytes_complete = float(biggest_file["size"]) * progress
                        mb_complete = bytes_complete / 1024.0 / 1024.0
                        buffer_percentage = (mb_complete / float(
                            plugin.get_setting("min_download_size"))) * 100
                        if buffer_percentage >= 100 and BUFFERSIZE != max_buffer_size:
                            extension_message = self.getExtensionMessage(
                                extension)
                        if extension_message == "File can not fast start. The whole file must download.":
                            BUFFERSIZE = max_buffer_size

                        if mb_complete > BUFFERSIZE or bytes_complete >= biggest_file[
                                "size"]:
                            extension_message = ""
                            dialog.update(
                                int(status["progress"] * 100),
                                *self._get_status_lines(
                                    status, extension_message))
                            plugin.log.info("Resolving to http://%s/files/%s" %
                                            (t2h_instance.bind_address,
                                             biggest_file["name"]))
                            has_resolved = True
                            item = {
                                "path":
                                "http://%s/files/%s" %
                                (t2h_instance.bind_address,
                                 urllib.quote(biggest_file["name"])),
                            }
                            if not xbmc.getInfoLabel("ListItem.Title"):
                                item["label"] = self.display_name
                            plugin.set_resolved_url(item)
                            break
                    xbmc.sleep(TORRENT2HTTP_POLL)

            # We are now playing
            plugin.log.info("Now playing torrent...")
            last_playing_event = 0
            with closing(
                    OverlayText(w=OVERLAY_WIDTH,
                                h=OVERLAY_HEIGHT,
                                alignment=XBFONT_CENTER_X
                                | XBFONT_CENTER_Y)) as overlay:
                with nested(
                        self.attach(overlay.show, self.on_playback_paused),
                        self.attach(overlay.hide, self.on_playback_resumed,
                                    self.on_playback_stopped)):
                    while not xbmc.abortRequested and self.isPlaying():
                        overlay.text = "\n".join(
                            self._get_status_lines(t2h("status"),
                                                   extension_message))
                        now = time.time()
                        if (now - last_playing_event) > PLAYING_EVENT_INTERVAL:
                            track_event("video", "playing", self.display_name)
                            last_playing_event = now
                        xbmc.sleep(TORRENT2HTTP_POLL)

        plugin.log.info("Closing Torrent player.")
import time
import subprocess
import xbmcaddon
from kmediatorrent.common import RESOURCES_PATH
from kmediatorrent.platform import PLATFORM
from kmediatorrent.utils import url_get
from kmediatorrent import plugin


ANDROID_XBMC_IDS = [
    "org.xbmc.kodi",                        # Stock XBMC Kodi
    "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_binary_dir():
    platform = PLATFORM.copy()
    if platform["os"] == "darwin": # 64 bits anyway on Darwin
        platform["arch"] = "x64"
    elif platform["os"] == "windows": # 32 bits anyway on Windows
        platform["arch"] = "x86"
Example #34
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.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
Example #35
0
from kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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("%s" % plugin.get_setting("btdigg_label"),
         "%s" % plugin.get_setting("btdigg_picture"))
@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 kmediatorrent import plugin
from kmediatorrent.scrapers import scraper
from kmediatorrent.ga import tracked
from kmediatorrent.caching import cached_route
from kmediatorrent.utils import ensure_fanart
from kmediatorrent.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("%s"%plugin.get_setting("bitsnoop_label"), "%s"%plugin.get_setting("bitsnoop_picture"))
@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 kmediatorrent.scrapers import rss