示例#1
0
def api_get_info(id, channel=''):
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    info = {}
    headers = {
        'Authorization':
        'Bearer {token}'.format(token=profile_settings['session_token'])
    }

    info_url = '{api_url}/assets/{channel}'.format(api_url=CONST_URLS['api'],
                                                   channel=id)

    download = api_download(url=info_url,
                            type='get',
                            headers=headers,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(data, 'id'):
        return info

    info = data

    info = plugin_process_info({'title': '', 'channel': channel, 'info': info})

    return info
示例#2
0
文件: api.py 项目: dut-iptv/dut-iptv
def api_get_info(id, channel=''):
    profile_settings = load_profile(profile_id=1)

    info = {}
    base_listing_url = CONST_URLS['listings_url']

    try:
        listing_url = '{listings_url}?byEndTime={time}~&byStationId={channel}&range=1-1&sort=startTime'.format(
            listings_url=base_listing_url,
            time=int(time.time() * 1000),
            channel=id)
        download = api_download(url=listing_url,
                                type='get',
                                headers=api_get_headers(),
                                data=None,
                                json_data=False,
                                return_json=True)
        data = download['data']
        code = download['code']

        if code and code == 200 and data and check_key(data, 'listings'):
            for row in data['listings']:
                if check_key(row, 'program'):
                    info = row['program']

        info = plugin_process_info({
            'title': '',
            'channel': channel,
            'info': info
        })
    except:
        pass

    return info
示例#3
0
文件: api.py 项目: dut-iptv/dut-iptv
def api_get_info(id, channel=''):
    profile_settings = load_profile(profile_id=1)

    info = {}
    friendly = ''

    data = api_get_channels()

    try:
        friendly = data[str(id)]['assetid']
    except:
        return info

    channel_url = '{base_url}/v7/epg/locations/{friendly}/live/1?fromDate={date}'.format(
        base_url=CONST_URLS['api'],
        friendly=friendly,
        date=datetime.datetime.now().strftime("%Y-%m-%dT%H%M%S"))

    download = api_download(url=channel_url,
                            type='get',
                            headers=None,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data:
        return info

    for row in data:
        if not check_key(row, 'Channel') or not check_key(row, 'Locations'):
            return info

        for row2 in row['Locations']:
            id = row2['LocationId']

    if not id:
        return info

    info_url = '{base_url}/v7/epg/location/{location}'.format(
        base_url=CONST_URLS['api'], location=id)

    download = api_download(url=info_url,
                            type='get',
                            headers=None,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data:
        return info

    info = data

    return plugin_process_info({'title': '', 'channel': channel, 'info': info})
示例#4
0
def api_get_info(id, channel=''):
    profile_settings = load_profile(profile_id=1)

    info = {}
    headers = {
        'Content-Type': 'application/json',
        'X_CSRFToken': profile_settings['csrf_token']
    }
    militime = int(time.time() * 1000)

    data = api_get_channels()

    session_post_data = {
        'needChannel': '0',
        'queryChannel': {
            'channelIDs': [
                id,
            ],
            'isReturnAllMedia': '1',
        },
        'queryPlaybill': {
            'count': '1',
            'endTime': militime,
            'isFillProgram': '1',
            'offset': '0',
            'startTime': militime,
            'type': '0',
        }
    }

    channel_url = '{base_url}/VSP/V3/QueryPlaybillListStcProps?SID=queryPlaybillListStcProps3&DEVICE=PC&DID={deviceID}&from=throughMSAAccess'.format(
        base_url=CONST_BASE_URL, deviceID=profile_settings['devicekey'])

    download = api_download(url=channel_url,
                            type='post',
                            headers=headers,
                            data=session_post_data,
                            json_data=True,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'result') or not check_key(
                data['result'], 'retCode'
            ) or not data['result']['retCode'] == '000000000' or not check_key(
                data, 'channelPlaybills') or not check_key(
                    data['channelPlaybills'][0],
                    'playbillLites') or not check_key(
                        data['channelPlaybills'][0]['playbillLites'][0], 'ID'):
        return info

    id = data['channelPlaybills'][0]['playbillLites'][0]['ID']

    session_post_data = {
        'playbillID': id,
        'channelNamespace': '310303',
        'isReturnAllMedia': '1',
    }

    program_url = '{base_url}/VSP/V3/QueryPlaybill?from=throughMSAAccess'.format(
        base_url=CONST_BASE_URL)

    download = api_download(url=program_url,
                            type='post',
                            headers=headers,
                            data=session_post_data,
                            json_data=True,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'result') or not check_key(
                data['result'], 'retCode'
            ) or not data['result']['retCode'] == '000000000' or not check_key(
                data, 'playbillDetail'):
        return info
    else:
        info = data['playbillDetail']

    info = plugin_process_info({'title': '', 'channel': channel, 'info': info})

    return info
示例#5
0
def play_video(type=None, channel=None, id=None, data=None, title=None, from_beginning=0, pvr=0, **kwargs):
    profile_settings = load_profile(profile_id=1)
    from_beginning = int(from_beginning)
    pvr = int(pvr)

    if not type or not len(unicode(type)) > 0:
        return False

    proxy_url = "http://127.0.0.1:11189/{provider}".format(provider=PROVIDER_NAME)

    code = 0

    try:
        test_proxy = api_download(url=proxy_url + "/status", type='get', headers=None, data=None, json_data=False, return_json=False)
        code = test_proxy['code']
    except:
        code = 404

    if not code or not code == 200:
        gui.ok(message=_.PROXY_NOT_SET)
        return False

    playdata = api_play_url(type=type, channel=channel, id=id, video_data=data, from_beginning=from_beginning, pvr=pvr)

    if not playdata or not check_key(playdata, 'path'):
        return False

    playdata['channel'] = channel
    playdata['title'] = title

    if check_key(playdata, 'alt_path') and (from_beginning == 1 or (settings.getBool(key='ask_start_from_beginning') and gui.yes_no(message=_.START_FROM_BEGINNING, heading=playdata['title']))):
        path = playdata['alt_path']
        license = playdata['alt_license']
    else:
        path = playdata['path']
        license = playdata['license']

    real_url = "{hostscheme}://{netloc}".format(hostscheme=urlparse(path).scheme, netloc=urlparse(path).netloc)

    path = path.replace(real_url, proxy_url)
    playdata['path'] = path
    playdata['license'] = license

    item_inputstream, CDMHEADERS = plugin_process_playdata(playdata)

    info = plugin_process_info(playdata)

    write_file(file='stream_hostname', data=real_url, isJSON=False)
    write_file(file='stream_duration', data=info['duration'], isJSON=False)

    listitem = plugin.Item(
        label = unicode(info['label1']),
        label2 = unicode(info['label2']),
        art = {
            'thumb': unicode(info['image']),
            'fanart': unicode(info['image_large'])
        },
        info = {
            'credits': info['credits'],
            'cast': info['cast'],
            'writer': info['writer'],
            'director': info['director'],
            'genre': info['genres'],
            'plot': unicode(info['description']),
            'duration': info['duration'],
            'mediatype': 'video',
            'year': info['year'],
            'sorttitle': unicode(info['label1']).upper(),
        },
        path = path,
        headers = CDMHEADERS,
        inputstream = item_inputstream,
    )

    return listitem