Beispiel #1
0
def vod_series(label, type, id, **kwargs):
    folder = plugin.Folder(title=label)

    items = []
    context = []

    seasons = api_vod_seasons(type, id)

    title = label

    if seasons and check_key(seasons, 'seasons'):
        if CONST_WATCHLIST and check_key(seasons, 'watchlist'):
            context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=seasons['watchlist'], type='group')), ))

        if seasons['type'] == "seasons":
            for season in seasons['seasons']:
                label = _.SEASON + " " + unicode(season['seriesNumber']).replace('Seizoen ', '')

                items.append(plugin.Item(
                    label = label,
                    info = {'plot': unicode(season['description']), 'sorttitle': label.upper()},
                    art = {
                        'thumb': unicode(season['image']),
                        'fanart': unicode(season['image'])
                    },
                    path = plugin.url_for(func_or_url=vod_season, label=label, series=id, id=unicode(season['id'])),
                    context = context,
                ))
        else:
            for episode in seasons['seasons']:
                items.append(plugin.Item(
                    label = unicode(episode['label']),
                    info = {
                        'plot': unicode(episode['description']),
                        'duration': episode['duration'],
                        'mediatype': 'video',
                        'sorttitle': unicode(episode['label']).upper(),
                    },
                    art = {
                        'thumb': unicode(episode['image']),
                        'fanart': unicode(episode['image'])
                    },
                    path = plugin.url_for(func_or_url=play_video, type='vod', channel=None, id=unicode(episode['id'])),
                    context = context,
                    playable = True,
                ))

        folder.add_items(items)

    return folder
Beispiel #2
0
def process_replaytv_search(search):
    now = datetime.datetime.now(pytz.timezone("Europe/Amsterdam"))
    sevendays = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7)
    nowstamp = int((now - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())
    sevendaysstamp = int((sevendays - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())

    search = unicode(search)

    data = api_get_channels()

    prefs = load_prefs(profile_id=1)
    channels_ar = []

    if prefs:
        for row in prefs:
            currow = prefs[row]

            if not check_key(data, unicode(row)):
                continue

            if int(currow['replay']) == 1:
                channels_ar.append(row)

    data = api_get_list(start=nowstamp, end=sevendaysstamp, channels=channels_ar)

    items = []

    if not data:
        return {'items': items}

    for currow in data:
        row = data[currow]

        title = unicode(row['title'])
        icon = unicode(row['icon'])

        fuzz_set = fuzz.token_set_ratio(title, search)
        fuzz_partial = fuzz.partial_ratio(title, search)
        fuzz_sort = fuzz.token_sort_ratio(title, search)

        if (fuzz_set + fuzz_partial + fuzz_sort) > 160:
            label = title + ' (ReplayTV)'
            idtitle = unicode(currow)

            items.append(plugin.Item(
                label = label,
                info = {
                    'sorttitle': label.upper(),
                },
                art = {
                    'thumb': icon,
                    'fanart': icon
                },
                properties = {"fuzz_set": fuzz_set, "fuzz_sort": fuzz_sort, "fuzz_partial": fuzz_partial, "fuzz_total": fuzz_set + fuzz_partial + fuzz_sort},
                path = plugin.url_for(func_or_url=replaytv_item, label=label, idtitle=idtitle, start=0),
            ))

    returnar = {'items': items}

    return returnar
Beispiel #3
0
def vod_season(label, series, id, **kwargs):
    folder = plugin.Folder(title=label)

    items = []

    season = api_vod_season(series=series, id=id)

    for episode in season:
        items.append(plugin.Item(
            label = unicode(episode['label']),
            info = {
                'plot': unicode(episode['description']),
                'duration': episode['duration'],
                'mediatype': 'video',
                'sorttitle': unicode(episode['label']).upper(),
            },
            art = {
                'thumb': unicode(episode['image']),
                'fanart': unicode(episode['image'])
            },
            path = plugin.url_for(func_or_url=play_video, type='vod', channel=None, id=unicode(episode['id']), data=json.dumps(episode)),
            playable = True,
        ))

    folder.add_items(items)

    return folder
Beispiel #4
0
def renew_token(**kwargs):
    data = {}

    for key, value in kwargs.items():
        data[key] = value

    mod_path = plugin_renew_token(data)

    listitem = plugin.Item(
        path = mod_path,
    )

    newItem = listitem.get_li()

    xbmcplugin.addDirectoryItem(ADDON_HANDLE, mod_path, newItem)
    xbmcplugin.endOfDirectory(ADDON_HANDLE, cacheToDisc=False)

    if xbmc.Monitor().waitForAbort(0.1):
        return None
Beispiel #5
0
def process_replaytv_content(station, day=0, start=0):
    day = int(day)
    start = int(start)
    curdate = datetime.date.today() - datetime.timedelta(days=day)

    startDate = convert_datetime_timezone(datetime.datetime(curdate.year, curdate.month, curdate.day, 0, 0, 0), "Europe/Amsterdam", "UTC")
    endDate = convert_datetime_timezone(datetime.datetime(curdate.year, curdate.month, curdate.day, 23, 59, 59), "Europe/Amsterdam", "UTC")
    startTimeStamp = int((startDate - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())
    endTimeStamp = int((endDate - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())

    data = api_get_epg_by_date_channel(date=curdate.strftime('%Y') + curdate.strftime('%m') + curdate.strftime('%d'), channel=station)

    items = []
    count = 0
    item_count = 0

    if not data:
        return {'items': items, 'count': item_count, 'count2': count, 'total': 0}

    for currow in data:
        row = data[currow]

        if item_count == 51:
            break

        count += 1

        if count < start + 1:
            continue

        context = []
        item_count += 1
        channel = unicode(row['channel'])

        startT = datetime.datetime.fromtimestamp(int(row['start']))
        startT = convert_datetime_timezone(startT, "Europe/Amsterdam", "Europe/Amsterdam")
        endT = datetime.datetime.fromtimestamp(int(row['end']))
        endT = convert_datetime_timezone(endT, "Europe/Amsterdam", "Europe/Amsterdam")

        if endT < (datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7)):
            continue

        label = startT.strftime("%H:%M") + " - " + unicode(row['title'])

        description = unicode(row['description'])

        duration = int((endT - startT).total_seconds())

        program_image = unicode(row['icon'])
        program_image_large = unicode(row['icon'])
        program_id = unicode(row['program_id'])

        if CONST_WATCHLIST:
            context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=program_id, type='item')), ))

        items.append(plugin.Item(
            label = label,
            info = {
                'plot': description,
                'duration': duration,
                'mediatype': 'video',
                'sorttitle': label.upper(),
            },
            art = {
                'thumb': program_image,
                'fanart': program_image_large
            },
            path = plugin.url_for(func_or_url=play_video, type='program', channel=channel, id=program_id),
            context = context,
            playable = True,
        ))

    returnar = {'items': items, 'count': item_count, 'count2': count, 'total': len(data)}

    return returnar
Beispiel #6
0
def process_replaytv_list(character, start=0):
    now = datetime.datetime.now(pytz.timezone("Europe/Amsterdam"))
    sevendays = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7)
    nowstamp = int((now - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())
    sevendaysstamp = int((sevendays - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())

    data = api_get_channels()

    prefs = load_prefs(profile_id=1)
    channels_ar = []

    if prefs:
        for row in prefs:
            currow = prefs[row]

            if not check_key(data, unicode(row)):
                continue

            if int(currow['replay']) == 1:
                channels_ar.append(row)

    data = api_get_list_by_first(first=character, start=nowstamp, end=sevendaysstamp, channels=channels_ar)

    start = int(start)
    items = []
    count = 0
    item_count = 0

    if not data:
        return {'items': items, 'count': item_count, 'count2': count, 'total': 0}

    for currow in data:
        row = data[currow]

        if item_count == 51:
            break

        count += 1

        if count < start + 1:
            continue

        item_count += 1

        label = unicode(row['title'])
        idtitle = unicode(currow)
        icon = unicode(row['icon'])

        items.append(plugin.Item(
            label = label,
            info = {
                'sorttitle': label.upper(),
            },
            art = {
                'thumb': icon,
                'fanart': icon
            },
            path = plugin.url_for(func_or_url=replaytv_item, label=label, idtitle=idtitle, start=0),
        ))

    returnar = {'items': items, 'count': item_count, 'count2': count, 'total': len(data)}

    return returnar
Beispiel #7
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
Beispiel #8
0
def process_vod_content(data, start=0, search=None, type=None, character=None, online=0):
    subscription_filter = plugin_vod_subscription_filter()

    start = int(start)
    type = unicode(type)
    type2 = data

    items = []

    if not online == 1:
        count = 0
    else:
        count = start

    item_count = 0

    if online == 1:
        if search:
            data = api_search(query=search)
        else:
            data = api_vod_download(type=data, start=start)
    else:
        data = api_get_vod_by_type(type=data, character=character, subscription_filter=subscription_filter)

    if not data:
        return {'items': items, 'count': item_count, 'count2': count, 'total': 0}

    for currow in data:
        if not online == 1:
            row = data[currow]
        else:
            row = currow

        if item_count == 51:
            break

        count += 1

        if not online == 1 and count < start + 1:
            continue

        id = unicode(row['id'])
        label = unicode(row['title'])

        if search and not online == 1:
            fuzz_set = fuzz.token_set_ratio(label,search)
            fuzz_partial = fuzz.partial_ratio(label,search)
            fuzz_sort = fuzz.token_sort_ratio(label,search)

            if (fuzz_set + fuzz_partial + fuzz_sort) > 160:
                properties = {"fuzz_set": fuzz.token_set_ratio(label,search), "fuzz_sort": fuzz.token_sort_ratio(label,search), "fuzz_partial": fuzz.partial_ratio(label,search), "fuzz_total": fuzz.token_set_ratio(label,search) + fuzz.partial_ratio(label,search) + fuzz.token_sort_ratio(label,search)}
                label = label + " (" + type + ")"
            else:
                continue

        context = []
        item_count += 1

        properties = []
        description = unicode(row['description'])
        duration = 0

        if row['duration'] and len(unicode(row['duration'])) > 0:
            duration = int(row['duration'])

        program_image = unicode(row['icon'])
        program_image_large = unicode(row['icon'])
        program_type = unicode(row['type'])

        if program_type == "show" or program_type == "Serie":
            path = plugin.url_for(func_or_url=vod_series, type=type2, label=label, id=id)
            info = {'plot': description, 'sorttitle': label.upper()}
            playable = False
        elif program_type == "Epg":
            path = plugin.url_for(func_or_url=play_video, type='program', channel=None, id=id)
            info = {'plot': description, 'duration': duration, 'mediatype': 'video', 'sorttitle': label.upper()}
            playable = True
        elif program_type == "movie" or program_type == "Vod":
            path = plugin.url_for(func_or_url=play_video, type='vod', channel=None, id=id)
            info = {'plot': description, 'duration': duration, 'mediatype': 'video', 'sorttitle': label.upper()}
            playable = True
        else:
            continue

        if CONST_WATCHLIST:
            context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=id, type='group')), ))

        items.append(plugin.Item(
            label = label,
            properties = properties,
            info = info,
            art = {
                'thumb': program_image,
                'fanart': program_image_large
            },
            path = path,
            playable = playable,
            context = context
        ))

    if not online == 1:
        total = len(data)
    else:
        total = int(len(data) + start)

    returnar = {'items': items, 'count': item_count, 'count2': count, 'total': total}

    return returnar
Beispiel #9
0
def process_replaytv_list_content(label, idtitle, start=0):
    start = int(start)

    now = datetime.datetime.now(pytz.timezone("Europe/Amsterdam"))
    sevendays = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7)
    nowstamp = int((now - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())
    sevendaysstamp = int((sevendays - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds())

    data = api_get_channels()

    prefs = load_prefs(profile_id=1)
    channels_ar = []
    channels_ar2 = {}

    if prefs:
        for row in prefs:
            currow = prefs[row]

            if not check_key(data, unicode(row)):
                continue

            channels_ar2[unicode(row)] = data[unicode(row)]['name']

            if int(currow['replay']) == 1:
                channels_ar.append(row)

    data = api_get_epg_by_idtitle(idtitle=idtitle, start=nowstamp, end=sevendaysstamp, channels=channels_ar)

    items = []
    count = 0
    item_count = 0

    if not data:
        return {'items': items, 'count': item_count, 'count2': count, 'total': 0}

    for currow in data:
        row = data[currow]

        if item_count == 51:
            break

        count += 1

        if count < start + 1:
            continue

        context = []
        item_count += 1

        channel = unicode(row['channel'])

        startT = datetime.datetime.fromtimestamp(int(row['start']))
        startT = convert_datetime_timezone(startT, "Europe/Amsterdam", "Europe/Amsterdam")
        endT = datetime.datetime.fromtimestamp(int(row['end']))
        endT = convert_datetime_timezone(endT, "Europe/Amsterdam", "Europe/Amsterdam")

        if xbmc.getLanguage(xbmc.ISO_639_1) == 'nl':
            itemlabel = '{weekday} {day} {month} {yearhourminute} '.format(weekday=date_to_nl_dag(startT), day=startT.strftime("%d"), month=date_to_nl_maand(startT), yearhourminute=startT.strftime("%Y %H:%M"))
        else:
            itemlabel = startT.strftime("%A %d %B %Y %H:%M ").capitalize()

        itemlabel += unicode(row['title'])

        try:
            itemlabel += " (" + unicode(channels_ar2[channel]) + ")"
        except:
            pass

        description = unicode(row['description'])
        duration = int((endT - startT).total_seconds())
        program_image = unicode(row['icon'])
        program_image_large = unicode(row['icon'])
        program_id = unicode(row['program_id'])

        if CONST_WATCHLIST:
            context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=program_id, type='item')), ))

        items.append(plugin.Item(
            label = itemlabel,
            info = {
                'plot': description,
                'duration': duration,
                'mediatype': 'video',
                'sorttitle': itemlabel.upper(),
            },
            art = {
                'thumb': program_image,
                'fanart': program_image_large
            },
            path = plugin.url_for(func_or_url=play_video, type='program', channel=channel, id=program_id),
            playable = True,
            context = context
        ))

    returnar = {'items': items, 'count': item_count, 'count2': count, 'total': len(data)}

    return returnar