Example #1
0
def url_get(url, params={}, headers={}, with_immunicity=True):
    import urllib2
    from contextlib import closing
    from kodipopcorntime import plugin
    from kodipopcorntime.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 kodipopcorntime 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 #2
0
    def init(self, uri, sub=None):
        self.subtitles = sub
        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 kodipopcorntime.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
Example #3
0
    "31" : "sr",
    "32" : "sl",
    "33" : "es",
    "34" : "sv",
    "35" : "th",
    "36" : "tr",
    "37" : "ur",
    "38" : "vi",
}

SUBTYPES = ['.srt']

def get_lang(sub_lang_id):
    return [ SUBLANG_EN[sub_lang_id], SUBLANG_ISO[sub_lang_id] ]

SUBLANG_EN_1, SUBLANG_ISO_1 = get_lang(plugin.get_setting("sub_language1"))
SUBLANG_EN_2, SUBLANG_ISO_2 = get_lang(plugin.get_setting("sub_language2"))
SUBLANG_EN_3, SUBLANG_ISO_3 = get_lang(plugin.get_setting("sub_language3"))

def get_sub_items(imdb_id):
    if SUBLANG_EN_1 == 'none':
        return None

    import urllib2
    from kodipopcorntime.utils import url_get_json
    try:
        data = url_get_json("%s/%s" % (API_BASE_URL, imdb_id), headers={"Referer":API_BASE_URL,}, with_immunicity=False) or {}
    except urllib2.HTTPError:
        return None

    if data["subtitles"] == 0:
Example #4
0
from os import path
from kodipopcorntime import plugin
from kodipopcorntime.caching import cached_route
from kodipopcorntime.utils import ensure_fanart
from kodipopcorntime.library import library_context
from kodipopcorntime.magnet import from_meta_data
import xbmcaddon

BASE_URL = "%s/" % plugin.get_setting("base_yify")
HEADERS = {
    "Referer": BASE_URL,
}
MOVIES_PER_PAGE = 20
GENRES = [
    "Action",
    "Adventure",
    "Animation",
    "Biography",
    "Comedy",
    "Crime",
    "Documentary",
    "Drama",
    "Family",
    "Fantasy",
    "Film-Noir",
    "Game-Show",
    "History",
    "Horror",
    "Music",
    "Musical",
    "Mystery",
import sys
import stat
import subprocess
from kodipopcorntime.common import RESOURCES_PATH
from kodipopcorntime.platform import PLATFORM
from kodipopcorntime.utils import url_get
from kodipopcorntime import plugin


ANDROID_XBMC_IDS = [
    "org.xbmc.kodi",                        # KODI XBMC
    "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"
Example #6
0
import os
import sys
import stat
import subprocess
from kodipopcorntime.common import RESOURCES_PATH
from kodipopcorntime.platform import PLATFORM
from kodipopcorntime.utils import url_get
from kodipopcorntime import plugin

ANDROID_XBMC_IDS = [
    "org.xbmc.kodi",  # KODI XBMC
    "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"
Example #7
0
from os import path
from kodipopcorntime import plugin
from kodipopcorntime.caching import cached_route
from kodipopcorntime.utils import ensure_fanart
from kodipopcorntime.library import library_context
from kodipopcorntime.magnet import from_meta_data
import xbmcaddon

BASE_URL = "%s/" % plugin.get_setting("base_yify")
HEADERS = {
    "Referer": BASE_URL,
}
MOVIES_PER_PAGE = 20
GENRES = [
    "Action",
    "Adventure",
    "Animation",
    "Biography",
    "Comedy",
    "Crime",
    "Documentary",
    "Drama",
    "Family",
    "Fantasy",
    "Film-Noir",
    "Game-Show",
    "History",
    "Horror",
    "Music",
    "Musical",
    "Mystery",