Ejemplo n.º 1
0
def play(plugin, channel_id, showtime=None, srno=None):
    with open(EXTRA_CHANNELS, "r") as f:
        extra = json.load(f)
    if showtime is None and extra.get(str(channel_id)):
        if extra.get(str(channel_id)).get("ext"):
            return extra.get(str(channel_id)).get("ext")
        return PLAY_EX_URL + extra.get(str(channel_id)).get("data")

    rjson = {"channel_id": int(channel_id), "stream_type": "Seek"}
    if showtime and srno:
        rjson["showtime"] = showtime
        rjson["srno"] = srno
        rjson["stream_type"] = "Catchup"

    resp = urlquick.post(GET_CHANNEL_URL, json=rjson).json()
    return Listitem().from_dict(
        **{
            "label": plugin._title,
            "callback": resp.get("result", "") + "?" +
            urlencode(getTokenParams()),
            "properties": {
                "IsPlayable":
                True,
                "inputstream":
                "inputstream.adaptive",
                "inputstream.adaptive.stream_headers":
                "User-Agent=KAIOS",
                "inputstream.adaptive.manifest_type":
                "hls",
                "inputstream.adaptive.license_key":
                urlencode(getTokenParams()) + "|" + urlencode(getHeaders()) +
                "|R{SSM}|",
            }
        })
Ejemplo n.º 2
0
def play_ex(plugin, dt=None):
    is_helper = inputstreamhelper.Helper(dt.get("proto", "mpd"),
                                         drm=dt.get("drm"))
    if is_helper.check_inputstream():
        licenseUrl = dt.get("lUrl") and dt.get("lUrl").replace(
            "{HEADERS}", urlencode(getHeaders())).replace(
                "{TOKEN}", urlencode(getTokenParams()))
        art = {}
        if dt.get("default_logo"):
            art['thumb'] = art['icon'] = IMG_CATCHUP + \
                dt.get("default_logo")
        return Listitem().from_dict(
            **{
                "label": dt.get("label") or plugin._title,
                "art": art or None,
                "callback": dt.get("pUrl"),
                "properties": {
                    "IsPlayable": True,
                    "inputstream": is_helper.inputstream_addon,
                    "inputstream.adaptive.stream_headers": dt.get("hdrs"),
                    "inputstream.adaptive.manifest_type": dt.get(
                        "proto", "mpd"),
                    "inputstream.adaptive.license_type": dt.get("drm"),
                    "inputstream.adaptive.license_key": licenseUrl,
                }
            })
Ejemplo n.º 3
0
 def getKey(self):
     global headers
     mp4 = self.path.split('/')[3]
     key = self.path.split('/')[4]
     effective_url = "https://tv.media.jio.com/streams_catchup/{0}/{1}/{2}".format(
         self.channel_name, mp4, key)
     if not headers:
         headers = utils.getHeaders()
     resp = ChannelRequestHandler.make_requests(effective_url, headers)
     self.proxy.send_response(resp.status_code)
     self.proxy.send_header('Content-Type', 'application/octet-stream')
     self.proxy.send_header('Content-Length', len(resp.content))
     self.proxy.end_headers()
     self.proxy.wfile.write(resp.content)
Ejemplo n.º 4
0
 def getKey(self):
     global headers
     key = self.path.split('/')[3]
     effective_url = "https://tv.media.jio.com/streams_live/{0}/{1}".format(
         self.channel_name, key)
     if not headers:
         headers = utils.getHeaders()
     resp = ChannelRequestHandler.make_requests(effective_url, headers)
     if resp.status_code == 411:
         kodiutils.notification(
             "Error", "JioTV can not be accessed from outside India")
     self.proxy.send_response(resp.status_code, 'OK')
     self.proxy.send_header('Content-Type', 'application/octet-stream')
     self.proxy.send_header('Connection', 'keep-alive')
     self.proxy.send_header('Content-Length', len(resp.content))
     self.proxy.end_headers()
     self.proxy.wfile.write(resp.content)
Ejemplo n.º 5
0
    def _find_valid_key(self, key):
        global headers
        if not headers:
            headers = utils.getHeaders()

        for _ in range(1, 15):
            effective_url = "https://tv.media.jio.com/streams_live/{0}/{1}".format(
                self.channel_name, key)
            resp = ChannelRequestHandler.make_requests(
                effective_url, headers, max_age=urlquick.MAX_AGE)
            timestamp = re.search("\-(\d{13})\.key", key).group(1)
            if resp.status_code == 200:
                return timestamp
            elif resp.status_code == 404:
                key = key.replace(timestamp, str(
                    int(timestamp)+(_*2000)) if _ % 2 == 0 else str(int(timestamp)-(_*2000)))
        return timestamp
Ejemplo n.º 6
0
    def resolveKey(self):
        global headers
        key = self.path.split('/')[-1]
        effective_url = "https://tv.media.jio.com/streams_live/{0}/{1}".format(
            self.channel_name, key)
        if not headers:
            headers = utils.getHeaders()
        resp = ChannelRequestHandler.make_requests(
            effective_url, headers, max_age=urlquick.MAX_AGE)

        if resp.status_code == 411 or resp.status_code == 451:
            Script.notify(
                "Error", "JioTV can not be accessed from outside India")
            self.proxy.send_error(resp.status_code)
        elif resp.status_code >= 400:
            self.proxy.send_error(resp.status_code)
        else:
            self.proxy.send_response(resp.status_code, 'OK')
            self.proxy.send_header('Content-Type', 'application/octet-stream')
            self.proxy.send_header('Connection', 'keep-alive')
            self.proxy.send_header('Content-Length', len(resp.content))
            self.proxy.end_headers()
            self.proxy.wfile.write(resp.content)
Ejemplo n.º 7
0
import re
import json
import time
import requests
from urlparse import parse_qs, urlparse
import SimpleHTTPServer
import base64
import threading
import os
from datetime import datetime
import hashlib
from xbmc import translatePath, log, LOGNOTICE
from resources.lib import utils, kodiutils

headers = utils.getHeaders()
qmap = {"Low": "_LOW", "Medium": "_MED", "High": "_HIG", "STB": "_STB"}

SERVER = "https://jiotv.live.cdn.jio.com"


class ChannelRequestHandler():
    def __init__(self, proxy):
        self.proxy = proxy
        p = urlparse(proxy.path)
        self.path = p.path
        self.params = parse_qs(p.query)
        play_url = self.path.endswith('master.m3u8')
        m3u8_url = self.path.endswith('.m3u8')
        ts_url = self.path.endswith('.ts')
        key_url = self.path.endswith('.key')