示例#1
0
def edit_channel_group(group, label):
    group = decode(group)
    xbmcplugin.setPluginCategory(_handle, label)
    channels_groups = Channels_groups()
    channels = Channels()
    channels_list = channels.get_channels_list(visible_filter=False)

    list_item = xbmcgui.ListItem(label='Přidat kanál')
    url = get_url(action='edit_channel_group_list_channels',
                  group=encode(group),
                  label=encode(group) + ' / Přidat kanál')
    xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
    list_item = xbmcgui.ListItem(label='Přidat všechny kanály')
    url = get_url(action='edit_channel_group_add_all_channels',
                  group=encode(group),
                  label=encode(group) + ' / Přidat kanál')
    xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
    if group in channels_groups.channels:
        for channel in channels_groups.channels[group]:
            if channel in channels_list:
                list_item = xbmcgui.ListItem(
                    label=channels_list[channel]['name'])
                url = get_url(action='edit_channel_group',
                              group=encode(group),
                              label=label)
                list_item.addContextMenuItems([(
                    'Smazat kanál',
                    'RunPlugin(plugin://' + plugin_id +
                    '?action=edit_channel_group_delete_channel&group=' +
                    quote(encode(group)) + '&channel=' +
                    quote(encode(channel)) + ')',
                )])
                xbmcplugin.addDirectoryItem(_handle, url, list_item, False)
    xbmcplugin.endOfDirectory(_handle, cacheToDisc=False)
示例#2
0
def load_o2_channels_list(serviceid, list):
    session = Session()
    channels = Channels()
    data = call_o2_api(
        url=
        'https://app.o2tv.cz/sws/subscription/settings/get-user-pref.json?name=nangu.channelListUserChannelNumbers',
        data=None,
        header=get_header(session.services[serviceid]))
    if 'err' in data:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s načtením seznamu kanálů',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    if 'listUserChannelNumbers' in data and len(
            data['listUserChannelNumbers']) > 0:
        for list_name in data['listUserChannelNumbers']:
            if list == encode(list_name):
                channels_list = channels.get_channels_list(
                    visible_filter=False)
                for channel in channels_list:
                    if channel in data['listUserChannelNumbers'][decode(list)]:
                        channels.set_visibility(channel, True)
                    else:
                        channels.set_visibility(channel, False)
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Seznam kanálů byl načtený',
                                      xbmcgui.NOTIFICATION_INFO, 5000)
    else:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s načtením seznamu kanálů',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
示例#3
0
def iptv_sc_download(channelName, startdatetime):
    addon = xbmcaddon.Addon()
    if addon.getSetting('download_streams') == 'true':
        from o2tv.downloader import add_to_queue
    epgId = -1
    from_ts = int(time.mktime(time.strptime(startdatetime, '%d.%m.%Y %H:%M')))
    channels = Channels()
    channels_list = channels.get_channels_list('name', visible_filter=False)
    channelName = decode(channelName)
    event = get_epgId_iptvsc(channelName,
                             channels_list[channelName]['channelKey'], from_ts)
    epgId = event['epgId']
    if epgId > 0:
        event = get_epg_details([epgId], update_from_api=1)
        if event['startTime'] > int(time.mktime(
                datetime.now().timetuple())) or event['endTime'] > int(
                    time.mktime(datetime.now().timetuple())):
            xbmcgui.Dialog().notification(
                'Sledování O2TV', 'Lze stáhnout jen už odvysílaný pořad!',
                xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()
        if event['availableTo'] < int(time.mktime(datetime.now().timetuple())):
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Pořad u O2 už není k dispozici!',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()
        add_to_queue(epgId, None)
    else:
        xbmcgui.Dialog().notification(
            'Sledování O2TV',
            'Pořad u O2 nenalezen! Používáte EPG z doplňku Sledování O2TV?',
            xbmcgui.NOTIFICATION_ERROR, 10000)
        sys.exit()
示例#4
0
def list_related(epgId, label):
    xbmcplugin.setPluginCategory(_handle, label)
    addon = xbmcaddon.Addon(id=plugin_id)

    channels = Channels()
    channels_list = channels.get_channels_list()

    data = call_o2_api(url='https://api.o2tv.cz/unity/api/v1/programs/' +
                       str(epgId) + '/related/?encodedChannels=' +
                       channels.get_encoded_channels() + '&isFuture=false',
                       data=None,
                       header=get_header_unity())
    if 'err' in data:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s načtením kategorie',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    if 'result' in data and len(data['result']) > 0:
        for event in data['result']:
            if event['channelKey'] in channels_list:
                startts = event['start'] / 1000
                start = datetime.fromtimestamp(event['start'] / 1000)
                endts = event['end'] / 1000
                end = datetime.fromtimestamp(event['end'] / 1000)
                epgId = event['epgId']
                list_item = xbmcgui.ListItem(
                    label=event['name'] + ' (' +
                    channels_list[event['channelKey']]['name'] + ' | ' +
                    decode(utils.day_translation_short[start.strftime('%w')]) +
                    ' ' + start.strftime('%d.%m %H:%M') + ' - ' +
                    end.strftime('%H:%M') + ')')
                list_item.setInfo(
                    'video', {
                        'mediatype':
                        'movie',
                        'title':
                        event['name'] + ' (' +
                        channels_list[event['channelKey']]['name'] + ')'
                    })
                list_item = get_listitem_epg_details(
                    list_item, str(event['epgId']),
                    channels_list[event['channelKey']]['logo'])
                list_item.setProperty('IsPlayable', 'true')
                list_item.setContentLookup(False)
                if addon.getSetting('download_streams') == 'true':
                    list_item.addContextMenuItems([
                        ('Stáhnout', 'RunPlugin(plugin://' + plugin_id +
                         '?action=add_to_queue&epgId=' + str(epgId) + ')')
                    ])
                url = get_url(action='play_archiv',
                              channelKey=encode(event['channelKey']),
                              start=startts,
                              end=endts,
                              epgId=epgId)
                xbmcplugin.addDirectoryItem(_handle, url, list_item, False)
            xbmcplugin.endOfDirectory(_handle)
    else:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Žádné pořady nenalezeny',
                                      xbmcgui.NOTIFICATION_INFO, 4000)
def future_program(channelKey, day, label):
    label = label.replace('Nahrávky / Plánování /', '')
    xbmcplugin.setPluginCategory(_handle, label)
    channels = Channels()
    channels_list = channels.get_channels_list()

    channelKey = decode(channelKey)
    if int(day) == 0:
        from_datetime = datetime.now()
        to_datetime = datetime.combine(date.today(), datetime.max.time())
    else:
        from_datetime = datetime.combine(
            date.today(), datetime.min.time()) + timedelta(days=int(day))
        to_datetime = datetime.combine(from_datetime, datetime.max.time())
    from_ts = int(time.mktime(from_datetime.timetuple()))
    to_ts = int(time.mktime(to_datetime.timetuple()))

    events = get_epg_ts(channelKey, from_ts, to_ts, 5)
    for key in sorted(events.keys()):
        epgId = events[key]['epgId']
        start = events[key]['start']
        end = events[key]['end']
        list_item = xbmcgui.ListItem(
            label=decode(utils.day_translation_short[start.strftime('%w')]) +
            ' ' + start.strftime('%d.%m %H:%M') + ' - ' +
            end.strftime('%H:%M') + ' | ' + events[key]['title'])
        list_item = get_listitem_epg_details(list_item, str(epgId),
                                             channels_list[channelKey]['logo'])
        list_item.setInfo('video', {
            'mediatype': 'movie',
            'title': events[key]['title']
        })
        list_item.setProperty('IsPlayable', 'false')
        list_item.addContextMenuItems([(
            'Přidat nahrávku',
            'RunPlugin(plugin://' + plugin_id +
            '?action=add_recording&channelKey=' + channelKey + '&epgId=' +
            str(epgId) + ')',
        )])
        url = get_url(action='add_recording',
                      channelKey=encode(channelKey),
                      epgId=epgId)
        xbmcplugin.addDirectoryItem(_handle, url, list_item, False)
    xbmcplugin.endOfDirectory(_handle)
示例#6
0
def select_channel_group(group):
    group = decode(group)
    channels_groups = Channels_groups()
    channels_groups.select_group(group)
    xbmc.executebuiltin('Container.Refresh')
    if (not group in channels_groups.channels
            or len(channels_groups.channels[group]) == 0) and group != 'all':
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Vybraná skupina je prázdná',
                                      xbmcgui.NOTIFICATION_WARNING, 5000)
示例#7
0
def delete_channel_group(group):
    response = xbmcgui.Dialog().yesno('Smazání skupiny kanálů',
                                      'Opravdu smazat skupinu kanálů ' +
                                      group + '?',
                                      nolabel='Ne',
                                      yeslabel='Ano')
    if response:
        group = decode(group)
        channels_groups = Channels_groups()
        channels_groups.delete_channels_group(group)
        xbmc.executebuiltin('Container.Refresh')
示例#8
0
def list_series(epgId, season, label):
    xbmcplugin.setPluginCategory(_handle, label)
    params = ''
    channels = Channels()
    channels_list = channels.get_channels_list()
    if int(season) > 0:
        params = params + '&seasonNumber=' + str(season)
    data = call_o2_api(
        url='https://api.o2tv.cz/unity/api/v1/programs/' + str(epgId) +
        '/episodes/?containsAllGenres=false&encodedChannels=' +
        channels.get_encoded_channels() + '&isFuture=false' + params,
        data=None,
        header=get_header_unity())
    if 'err' in data:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s načtením kategorie',
                                      xbmcgui.NOTIFICATION_ERROR, 4000)
        sys.exit()
    if 'result' in data and len(data['result']) > 0:
        for event in data['result']:
            if event['channelKey'] in channels_list:
                startts = event['start'] / 1000
                start = datetime.fromtimestamp(event['start'] / 1000)
                endts = event['end'] / 1000
                end = datetime.fromtimestamp(event['end'] / 1000)
                epgId = event['epgId']
                list_item = xbmcgui.ListItem(
                    label=event['name'] + ' (' +
                    channels_list[event['channelKey']]['name'] + ' | ' +
                    decode(utils.day_translation_short[start.strftime('%w')]) +
                    ' ' + start.strftime('%d.%m %H:%M') + ' - ' +
                    end.strftime('%H:%M') + ')')
                list_item.setInfo(
                    'video', {
                        'mediatype':
                        'movie',
                        'title':
                        event['name'] + ' (' +
                        channels_list[event['channelKey']]['name'] + ')'
                    })
                list_item = get_listitem_epg_details(
                    list_item, str(event['epgId']),
                    channels_list[event['channelKey']]['logo'])
                list_item.setProperty('IsPlayable', 'true')
                list_item.setContentLookup(False)
                url = get_url(action='play_archiv',
                              channelKey=encode(event['channelKey']),
                              start=startts,
                              end=endts,
                              epgId=epgId)
                xbmcplugin.addDirectoryItem(_handle, url, list_item, False)
        xbmcplugin.endOfDirectory(_handle)
示例#9
0
def edit_channel_group_list_channels(group, label):
    group = decode(group)
    xbmcplugin.setPluginCategory(_handle, label)
    channels_groups = Channels_groups()
    channels = Channels()
    channels_list = channels.get_channels_list('number', visible_filter=False)
    for number in sorted(channels_list.keys()):
        if not group in channels_groups.groups or not group in channels_groups.channels or not channels_list[
                number]['channelKey'] in channels_groups.channels[group]:
            list_item = xbmcgui.ListItem(label=str(number) + ' ' +
                                         channels_list[number]['name'])
            url = get_url(action='edit_channel_group_add_channel',
                          group=encode(group),
                          channel=encode(channels_list[number]['channelKey']))
            xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
    xbmcplugin.endOfDirectory(_handle, cacheToDisc=False)
示例#10
0
def edit_channel(channelKey):
    channelKey = decode(channelKey)
    channels = Channels()
    channels_list = channels.get_channels_list(visible_filter=False)
    new_num = xbmcgui.Dialog().numeric(
        0, 'Číslo kanálu', str(channels_list[channelKey]['number']))
    if len(new_num) > 0 and int(new_num) > 0:
        channels_nums = channels.get_channels_list('number',
                                                   visible_filter=False)
        if int(new_num) in channels_nums:
            xbmcgui.Dialog().notification(
                'Sledování O2TV',
                'Číslo kanálu ' + new_num + ' je použité u kanálu ' +
                encode(channels_nums[int(new_num)]['name']),
                xbmcgui.NOTIFICATION_ERROR, 5000)
        else:
            channels.set_number(channelKey, new_num)
示例#11
0
def iptv_sc_rec(channelName, startdatetime):
    epgId = -1
    channels = Channels()
    channels_list = channels.get_channels_list('name', visible_filter=False)
    channelName = decode(channelName)
    from_ts = int(time.mktime(time.strptime(startdatetime, '%d.%m.%Y %H:%M')))
    event = get_epgId_iptvsc(channelName,
                             channels_list[channelName]['channelKey'], from_ts)
    epgId = event['epgId']
    if epgId > 0:
        add_recording(channels_list[channelName]['channelKey'], epgId)
    else:
        xbmcgui.Dialog().notification(
            'Sledování O2TV',
            'Pořad u O2 nenalezen! Používáte EPG z doplňku Sledování O2TV?',
            xbmcgui.NOTIFICATION_ERROR, 10000)
        sys.exit()
def add_recording(channelKey, epgId):
    channelKey = decode(channelKey)
    channels = Channels()
    channels_list = channels.get_channels_list()
    session = Session()
    service = session.get_service(channels_list[channelKey]['serviceid'])
    post = {'epgId': int(epgId)}
    data = call_o2_api(
        url='https://app.o2tv.cz/sws/subscription/vod/pvr-add-program.json',
        data=post,
        header=get_header(service))
    if 'err' in data:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s přidáním nahrávky',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    xbmcgui.Dialog().notification('Sledování O2TV', 'Nahrávka přidána',
                                  xbmcgui.NOTIFICATION_INFO, 5000)
def delete_recording(channelKey, pvrProgramId):
    channelKey = decode(channelKey)
    channels = Channels()
    channels_list = channels.get_channels_list(visible_filter=False)
    session = Session()
    service = session.get_service(channels_list[channelKey]['serviceid'])
    post = {'pvrProgramId': int(pvrProgramId)}
    data = call_o2_api(
        url='https://app.o2tv.cz/sws/subscription/vod/pvr-remove-program.json',
        data=post,
        header=get_header(service))
    if data != None and 'err' in data:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s odstraněním nahrávky',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    else:
        xbmcgui.Dialog().notification('Sledování O2TV', 'Nahrávka odstraněna',
                                      xbmcgui.NOTIFICATION_INFO, 5000)
    xbmc.executebuiltin('Container.Refresh')
示例#14
0
def add_channel_group(label):
    input = xbmc.Keyboard('', 'Název skupiny')
    input.doModal()
    if not input.isConfirmed():
        return
    group = input.getText()
    if len(group) == 0:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Je nutné zadat název skupiny',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    group = decode(group)
    channels_groups = Channels_groups()
    if group in channels_groups.groups:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Název skupiny je už použitý',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    channels_groups.add_channels_group(group)
    xbmc.executebuiltin('Container.Refresh')
def list_rec_days(channelKey, label):
    xbmcplugin.setPluginCategory(_handle, label)
    for i in range(10):
        day = date.today() + timedelta(days=i)
        if i == 0:
            den_label = 'Dnes'
            den = 'Dnes'
        elif i == 1:
            den_label = 'Zítra'
            den = 'Zítra'
        else:
            den_label = utils.day_translation_short[day.strftime(
                '%w')] + ' ' + day.strftime('%d.%m')
            den = decode(utils.day_translation[day.strftime(
                '%w')]) + ' ' + day.strftime('%d.%m.%Y')
        list_item = xbmcgui.ListItem(label=den)
        url = get_url(action='future_program',
                      channelKey=channelKey,
                      day=i,
                      label=label + ' / ' + den_label)
        xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
    xbmcplugin.endOfDirectory(_handle)
def list_future_recordings(label):
    xbmcplugin.setPluginCategory(_handle, label)
    channels = Channels()
    channels_list = channels.get_channels_list()
    session = Session()
    recordings = {}

    for serviceid in session.get_services():
        data = call_o2_api(url='https://api.o2tv.cz/unity/api/v1/recordings/',
                           data=None,
                           header=get_header_unity(
                               session.services[serviceid]))
        if 'err' in data:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s načtením nahrávek',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
        if 'result' in data and len(data['result']) > 0:
            for program in data['result']:
                if program['state'] != 'DONE' and program['program'][
                        'channelKey'] in channels_list:
                    recordings.update({
                        program['program']['start'] + random.randint(0, 100): {
                            'pvrProgramId':
                            program['pvrProgramId'],
                            'name':
                            program['program']['name'],
                            'channelKey':
                            program['program']['channelKey'],
                            'start':
                            decode(utils.day_translation_short[
                                datetime.fromtimestamp(
                                    program['program']['start'] /
                                    1000).strftime('%w')]) + ' ' +
                            datetime.fromtimestamp(
                                program['program']['start'] /
                                1000).strftime('%d.%m %H:%M'),
                            'end':
                            datetime.fromtimestamp(program['program']['end'] /
                                                   1000).strftime('%H:%M'),
                            'epgId':
                            program['program']['epgId']
                        }
                    })

        if len(recordings) > 0:
            for recording in sorted(recordings.keys(), reverse=True):
                list_item = xbmcgui.ListItem(
                    label=recordings[recording]['name'] + ' (' +
                    recordings[recording]['channelKey'] + ' | ' +
                    recordings[recording]['start'] + ' - ' +
                    recordings[recording]['end'] + ')')
                list_item.setInfo(
                    'video', {
                        'mediatype':
                        'movie',
                        'title':
                        recordings[recording]['name'] + ' (' +
                        recordings[recording]['channelKey'] + ')'
                    })
                list_item.setProperty('IsPlayable', 'true')
                list_item = get_listitem_epg_details(
                    list_item, recordings[recording]['epgId'],
                    channels_list[recordings[recording]['channelKey']]['logo'])
                list_item.addContextMenuItems([(
                    'Smazat nahrávku',
                    'RunPlugin(plugin://' + plugin_id +
                    '?action=delete_recording&channelKey=' +
                    recordings[recording]['channelKey'] + '&pvrProgramId=' +
                    str(recordings[recording]['pvrProgramId']) + ')',
                )])
                url = get_url(action='list_future_recordings')
                xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
            xbmcplugin.endOfDirectory(_handle, cacheToDisc=False)
        else:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Nenalezena žádná nahrávka',
                                          xbmcgui.NOTIFICATION_INFO, 5000)
            sys.exit()
def list_recordings(label):
    xbmcplugin.setPluginCategory(_handle, label)
    addon = xbmcaddon.Addon()

    channels = Channels()
    channels_list = channels.get_channels_list(visible_filter=False)
    session = Session()
    recordings = {}

    list_item = xbmcgui.ListItem(label='Plánování nahrávek')
    url = get_url(action='list_planning_recordings',
                  label=label + ' / ' + 'Plánování')
    xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
    list_item = xbmcgui.ListItem(label='Naplánované nahrávky')
    url = get_url(action='list_future_recordings',
                  label=label + ' / ' + 'Naplánované nahrávky')
    xbmcplugin.addDirectoryItem(_handle, url, list_item, True)

    for serviceid in session.get_services():
        data = call_o2_api(url='https://api.o2tv.cz/unity/api/v1/recordings/',
                           data=None,
                           header=get_header_unity(
                               session.services[serviceid]))
        if 'err' in data:
            xbmcgui.Dialog().notification(
                'Sledování O2TV',
                'Problém s načtením nahrávek, zkuste to znovu',
                xbmcgui.NOTIFICATION_ERROR, 6000)
        if 'result' in data and len(data['result']) > 0:
            for program in data['result']:
                if program['state'] == 'DONE':
                    recordings.update({
                        program['program']['start'] + random.randint(0, 100): {
                            'pvrProgramId':
                            program['pvrProgramId'],
                            'name':
                            program['program']['name'],
                            'channelKey':
                            program['program']['channelKey'],
                            'start':
                            decode(utils.day_translation_short[
                                datetime.fromtimestamp(
                                    program['program']['start'] /
                                    1000).strftime('%w')]) + ' ' +
                            datetime.fromtimestamp(
                                program['program']['start'] /
                                1000).strftime('%d.%m %H:%M'),
                            'end':
                            datetime.fromtimestamp(program['program']['end'] /
                                                   1000).strftime('%H:%M'),
                            'epgId':
                            program['program']['epgId']
                        }
                    })

    for recording in sorted(recordings.keys(), reverse=True):
        if recordings[recording]['channelKey'] in channels_list:
            list_item = xbmcgui.ListItem(
                label=recordings[recording]['name'] + ' (' +
                recordings[recording]['channelKey'] + ' | ' +
                recordings[recording]['start'] + ' - ' +
                recordings[recording]['end'] + ')')
            list_item.setProperty('IsPlayable', 'true')
            list_item.setInfo(
                'video', {
                    'mediatype':
                    'movie',
                    'title':
                    recordings[recording]['name'] + ' (' +
                    recordings[recording]['channelKey'] + ')'
                })
            list_item = get_listitem_epg_details(
                list_item, recordings[recording]['epgId'],
                channels_list[recordings[recording]['channelKey']]['logo'])
            list_item.setContentLookup(False)
            menus = [('Smazat nahrávku', 'RunPlugin(plugin://' + plugin_id +
                      '?action=delete_recording&channelKey=' +
                      recordings[recording]['channelKey'] + '&pvrProgramId=' +
                      str(recordings[recording]['pvrProgramId']) + ')')]
            if addon.getSetting('download_streams') == 'true':
                menus.append(
                    ('Stáhnout', 'RunPlugin(plugin://' + plugin_id +
                     '?action=add_to_queue&epgId=' +
                     str(recordings[recording]['epgId']) + '&pvrProgramId=' +
                     str(recordings[recording]['pvrProgramId']) + ')'))
            list_item.addContextMenuItems(menus)
            url = get_url(action='play_recording',
                          channelKey=encode(
                              recordings[recording]['channelKey']),
                          pvrProgramId=recordings[recording]['pvrProgramId'],
                          title=encode(recordings[recording]['name']))
            xbmcplugin.addDirectoryItem(_handle, url, list_item, False)
    xbmcplugin.endOfDirectory(_handle, cacheToDisc=False)
示例#18
0
def delete_channel(channelKey):
    channelKey = decode(channelKey)
    channels = Channels()
    channels.delete_channel(channelKey)
    xbmc.executebuiltin('Container.Refresh')
示例#19
0
def edit_channel_group_delete_channel(group, channel):
    group = decode(group)
    channel = decode(channel)
    channels_groups = Channels_groups()
    channels_groups.delete_channel_from_group(channel, group)
    xbmc.executebuiltin('Container.Refresh')
示例#20
0
def iptv_sc_play(channelName, startdatetime, epg):
    epgId = -1
    addon = xbmcaddon.Addon()
    channelName = decode(channelName)
    if len(startdatetime) > 0:
        from_ts = int(
            time.mktime(time.strptime(startdatetime, '%d.%m.%Y %H:%M')))
    else:
        from_ts = int(time.mktime(datetime.now().timetuple()))

    channels = Channels()
    channels_list = channels.get_channels_list('name', visible_filter=False)
    if channelName not in channels_list:
        xbmcgui.Dialog().notification(
            'Sledování O2TV', 'Kanál přehrávaný z IPTV SC nebyl nalezený!',
            xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    channelKey = channels_list[channelName]['channelKey']

    if from_ts > int(time.mktime(datetime.now().timetuple())):
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Nelze přehrát budoucí pořad!',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    else:
        event = get_epgId_iptvsc(channelName, channelKey, from_ts)
        epgId = event['epgId']
        if epgId > 0:
            startts = event['start']
            start = datetime.fromtimestamp(event['start'])
            endts = event['end']
            end = datetime.fromtimestamp(event['end'])
            epgId = event['epgId']
            title = decode(
                utils.day_translation_short[start.strftime('%w')]
            ) + ' ' + start.strftime('%d.%m %H:%M') + ' - ' + end.strftime(
                '%H:%M') + ' | ' + event['title']

        if int(epgId) > 0:
            if int(endts) < int(time.mktime(datetime.now().timetuple())):
                play_video(type='archiv_iptv',
                           channelKey=encode(channelKey),
                           start=startts,
                           end=endts,
                           epgId=epgId,
                           title=title)
            else:
                if epg == 1:
                    play_video(type='live_iptv_epg',
                               channelKey=encode(channelKey),
                               start=None,
                               end=None,
                               epgId=None,
                               title=None)
                else:
                    play_video(type='live_iptv',
                               channelKey=encode(channelKey),
                               start=None,
                               end=None,
                               epgId=None,
                               title=None)
        else:
            if len(startdatetime) == 0:
                play_video(type='live_iptv',
                           channelKey=encode(channelKey),
                           start=None,
                           end=None,
                           epgId=None,
                           title=None)
            else:
                xbmcgui.Dialog().notification(
                    'Sledování O2TV',
                    'Pořad u O2 nenalezen! Používáte EPG z doplňku Sledování O2TV?',
                    xbmcgui.NOTIFICATION_ERROR, 10000)
            sys.exit()
def list_program(channelKey, day_min, label):
    label = label.replace('Archiv /', '')
    xbmcplugin.setPluginCategory(_handle, label)
    addon = xbmcaddon.Addon()
    channelKey = decode(channelKey)
    channels = Channels()
    channels_list = channels.get_channels_list()
    if int(day_min) == 0:
        from_datetime = datetime.combine(date.today(), datetime.min.time())
        to_datetime = datetime.now()
    else:
        from_datetime = datetime.combine(
            date.today(), datetime.min.time()) - timedelta(days=int(day_min))
        to_datetime = datetime.combine(from_datetime, datetime.max.time())
    from_ts = int(time.mktime(from_datetime.timetuple()))
    to_ts = int(time.mktime(to_datetime.timetuple()))

    events = {}
    events = get_epg_ts(channelKey, from_ts, to_ts, 8)

    if addon.getSetting('archive_reverse_sort') == "true":
        archive_reverse = True
    else:
        archive_reverse = False

    for key in sorted(events.keys(), reverse=archive_reverse):
        if int(events[key]['endts']) > int(
                time.mktime(datetime.now().timetuple())) - 60 * 60 * 24 * 7:
            list_item = xbmcgui.ListItem(
                label=decode(utils.day_translation_short[
                    events[key]['start'].strftime('%w')]) + ' ' +
                events[key]['start'].strftime('%d.%m %H:%M') + ' - ' +
                events[key]['end'].strftime('%H:%M') + ' | ' +
                events[key]['title'])
            list_item.setInfo('video', {
                'mediatype': 'movie',
                'title': events[key]['title']
            })
            list_item = get_listitem_epg_details(
                list_item, str(events[key]['epgId']),
                channels_list[channelKey]['logo'])
            list_item.setProperty('IsPlayable', 'true')
            list_item.setContentLookup(False)
            menus = [
                ('Přidat nahrávku', 'RunPlugin(plugin://' + plugin_id +
                 '?action=add_recording&channelKey=' + channelKey + '&epgId=' +
                 str(events[key]['epgId']) + ')'),
                ('Související pořady',
                 'Container.Update(plugin://' + plugin_id +
                 '?action=list_related&epgId=' + str(events[key]['epgId']) +
                 '&label=Související / ' + encode(events[key]['title']) + ')'),
                ('Vysílání pořadu', 'Container.Update(plugin://' + plugin_id +
                 '?action=list_same&epgId=' + str(events[key]['epgId']) +
                 '&label=' + encode(events[key]['title']) + ')')
            ]
            if addon.getSetting('download_streams') == 'true':
                menus.append(('Stáhnout', 'RunPlugin(plugin://' + plugin_id +
                              '?action=add_to_queue&epgId=' +
                              str(events[key]['epgId']) + ')'))
            list_item.addContextMenuItems(menus)
            url = get_url(action='play_archiv',
                          channelKey=encode(channelKey),
                          start=events[key]['startts'],
                          end=events[key]['endts'],
                          epgId=events[key]['epgId'])
            xbmcplugin.addDirectoryItem(_handle, url, list_item, False)
    xbmcplugin.endOfDirectory(_handle, cacheToDisc=False)
示例#22
0
def list_category(category, dataSource, filtr, page, label):
    xbmcplugin.setPluginCategory(_handle, label)
    addon = xbmcaddon.Addon()
    page_limit = int(addon.getSetting('category_pagesize'))
    filtr = json.loads(filtr)
    params = ''
    genres = []
    nongenres = []
    for genre in filtr['genres']:
        if len(genre) > 0:
            params = params + '&genres=' + quote_plus(encode(genre))
            genres.append(genre)
    for nongenre in filtr['notGenres']:
        if len(nongenre) > 0:
            params = params + '&notGenres=' + quote_plus(encode(nongenre))
            nongenres.append(nongenre)
    contentType = filtr['contentType']

    channels = Channels()
    channels_list = channels.get_channels_list()

    events = {}
    data = call_o2_api(
        url='https://api.o2tv.cz' + dataSource + '?containsAllGenres=' +
        str(filtr['containsAllGenres']).lower() + '&contentType=' +
        contentType + params + '&encodedChannels=' +
        channels.get_encoded_channels() +
        '&sort=-o2rating&grouped=true&isFuture=false&limit=500&offset=0',
        data=None,
        header=get_header_unity())
    if 'err' in data:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s načtením kategorie',
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()
    if 'result' in data and len(data['result']) > 0:
        num = 0
        cnt = 0
        characters = []
        for event in data['result']:
            cnt = cnt + 1
            if addon.getSetting('categories_sorting') == 'ratingu':
                events.update({num: event})
                num = num + 1
            else:
                events.update({remove_diacritics(event['name']): event})
                if remove_diacritics(
                        event['name'][:1].upper()) not in characters:
                    characters.append(
                        remove_diacritics(event['name'][:1].upper()))
        if addon.getSetting(
                'categories_sorting'
        ) == 'názvu' and page is None and page_limit > 0 and len(
                events) > page_limit:
            characters.sort()
            for character in characters:
                list_item = xbmcgui.ListItem(label=character)
                url = get_url(action='list_category',
                              category=contentType,
                              dataSource=dataSource,
                              filtr=json.dumps(filtr),
                              page=encode(character),
                              label=label + ' / ' +
                              encode(character.decode('utf-8')))
                xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
        else:
            if addon.getSetting(
                    'categories_sorting') == 'ratingu' and page_limit > 0:
                if page is None:
                    page = 1
                startitem = (int(page) - 1) * page_limit
            cnt = 0
            for key in sorted(events.keys()):
                if page is None or page_limit == 0 or (
                        page is not None
                        and addon.getSetting('categories_sorting') == 'názvu'
                        and remove_diacritics(events[key]['name'][:1].upper())
                        == page.encode('utf-8')
                ) or (page is not None
                      and addon.getSetting('categories_sorting') == 'ratingu'
                      and cnt >= startitem and cnt < startitem + page_limit):
                    event = events[key]
                    startts = event['start'] / 1000
                    start = datetime.fromtimestamp(event['start'] / 1000)
                    endts = event['end'] / 1000
                    end = datetime.fromtimestamp(event['end'] / 1000)
                    epgId = event['epgId']
                    isSeries = 0
                    if event['channelKey'] in channels_list:
                        if 'seriesInfo' in event and 'seriesName' in event[
                                'seriesInfo'] and len(
                                    event['seriesInfo']['seriesName']) > 0:
                            isSeries = 1
                            event['name'] = event['seriesInfo']['seriesName']
                            if 'seasonNumber' in event['seriesInfo']:
                                event['name'] = event[
                                    'name']  # + ' ['+ str(event['seriesInfo']['seasonNumber']) + ']'
                            list_item = xbmcgui.ListItem(
                                label=event['name'] + ' (' +
                                channels_list[event['channelKey']]['name'] +
                                ')')
                        else:
                            list_item = xbmcgui.ListItem(
                                label=event['name'] + ' (' +
                                channels_list[event['channelKey']]['name'] +
                                ' | ' + decode(utils.day_translation_short[
                                    start.strftime('%w')]) + ' ' +
                                start.strftime('%d.%m %H:%M') + ' - ' +
                                end.strftime('%H:%M') + ')')
                        cast = []
                        directors = []
                        genres = []
                        list_item.setInfo(
                            'video', {
                                'mediatype':
                                'movie',
                                'title':
                                event['name'] + ' (' +
                                channels_list[event['channelKey']]['name'] +
                                ')'
                            })
                        if 'images' in event and len(event['images']) > 0:
                            list_item.setArt({
                                'poster':
                                'https://img1.o2tv.cz/' +
                                event['images'][0]['cover'],
                                'thumb':
                                'https://img1.o2tv.cz/' +
                                event['images'][0]['cover'],
                                'icon':
                                'https://img1.o2tv.cz/' +
                                event['images'][0]['cover']
                            })
                        if 'longDescription' in event and len(
                                event['longDescription']) > 0:
                            list_item.setInfo(
                                'video', {'plot': event['longDescription']})
                        if 'ratings' in event and len(event['ratings']) > 0:
                            for rating, rating_value in event['ratings'].items(
                            ):
                                list_item.setRating(rating,
                                                    int(rating_value) / 10)
                        if 'castAndCrew' in event and len(
                                event['castAndCrew']
                        ) > 0 and 'cast' in event['castAndCrew'] and len(
                                event['castAndCrew']['cast']) > 0:
                            for person in event['castAndCrew']['cast']:
                                cast.append(encode(person['name']))
                            list_item.setInfo('video', {'cast': cast})
                        if 'castAndCrew' in event and len(
                                event['castAndCrew']
                        ) > 0 and 'directors' in event['castAndCrew'] and len(
                                event['castAndCrew']['directors']) > 0:
                            for person in event['castAndCrew']['directors']:
                                directors.append(encode(person['name']))
                            list_item.setInfo('video', {'director': directors})
                        if 'origin' in event and len(event['origin']) > 0:
                            if 'year' in event['origin'] and len(
                                    str(event['origin']['year'])) > 0:
                                list_item.setInfo(
                                    'video', {'year': event['origin']['year']})
                            if 'country' in event['origin'] and len(
                                    event['origin']['country']) > 0:
                                list_item.setInfo('video', {
                                    'country':
                                    event['origin']['country']['name']
                                })
                        if 'origName' in event and len(event['origName']) > 0:
                            list_item.setInfo(
                                'video', {'originaltitle': event['origName']})
                        if 'ext' in event and len(
                                event['ext']) > 0 and 'imdbId' in event[
                                    'ext'] and len(event['ext']['imdbId']) > 0:
                            list_item.setInfo(
                                'video',
                                {'imdbnumber': event['ext']['imdbId']})
                        if 'genreInfo' in event and len(
                                event['genreInfo']
                        ) > 0 and 'genres' in event['genreInfo'] and len(
                                event['genreInfo']['genres']) > 0:
                            for genre in event['genreInfo']['genres']:
                                genres.append(encode(genre['name']))
                            list_item.setInfo('video', {'genre': genres})
                        menus = [
                            ('Související pořady',
                             'Container.Update(plugin://' + plugin_id +
                             '?action=list_related&epgId=' + str(epgId) +
                             '&label=Související / ' + encode(event['name']) +
                             ')'),
                            ('Vysílání pořadu',
                             'Container.Update(plugin://' + plugin_id +
                             '?action=list_same&epgId=' + str(epgId) +
                             '&label=' + encode(event['name']) + ')'),
                            ('Přidat nahrávku', 'RunPlugin(plugin://' +
                             plugin_id + '?action=add_recording&channelKey=' +
                             event['channelKey'] + '&epgId=' + str(epgId) +
                             ')')
                        ]
                        if addon.getSetting('download_streams') == 'true':
                            menus.append(
                                ('Stáhnout', 'RunPlugin(plugin://' +
                                 plugin_id + '?action=add_to_queue&epgId=' +
                                 str(epgId) + ')'))
                        list_item.addContextMenuItems(menus)
                        if isSeries == 0:
                            list_item.setProperty('IsPlayable', 'true')
                            list_item.setContentLookup(False)
                            url = get_url(action='play_archiv',
                                          channelKey=encode(
                                              event['channelKey']),
                                          start=startts,
                                          end=endts,
                                          epgId=epgId)
                            xbmcplugin.addDirectoryItem(
                                _handle, url, list_item, False)
                        else:
                            if 'seasonNumber' in event['seriesInfo'] and int(
                                    event['seriesInfo']['seasonNumber']) > 0:
                                season = int(
                                    event['seriesInfo']['seasonNumber'])
                            else:
                                season = -1
                            list_item.setProperty('IsPlayable', 'false')
                            url = get_url(action='list_series',
                                          epgId=epgId,
                                          season=season,
                                          label=encode(event['name']))
                            xbmcplugin.addDirectoryItem(
                                _handle, url, list_item, True)
                cnt = cnt + 1

            if page is not None and addon.getSetting(
                    'categories_sorting'
            ) == 'ratingu' and int(page) * page_limit <= cnt:
                list_item = xbmcgui.ListItem(label='další strana')
                url = get_url(action='list_category',
                              category=contentType,
                              dataSource=dataSource,
                              filtr=json.dumps(filtr),
                              page=int(page) + 1,
                              label=label)
                list_item.setProperty('IsPlayable', 'false')
                xbmcplugin.addDirectoryItem(_handle, url, list_item, True)
    xbmcplugin.endOfDirectory(_handle)
示例#23
0
def edit_channel_group_add_channel(group, channel):
    group = decode(group)
    channel = decode(channel)
    channels_groups = Channels_groups()
    channels_groups.add_channel_to_group(channel, group)
    xbmc.executebuiltin('Container.Refresh')
示例#24
0
def edit_channel_group_add_all_channels(group):
    group = decode(group)
    channels_groups = Channels_groups()
    channels_groups.add_all_channels_to_group(group)
    xbmc.executebuiltin('Container.Refresh')
def play_video(type, channelKey, start, end, epgId, title):
    addon = xbmcaddon.Addon()
    session = Session()
    channelKey = decode(channelKey)
    channels = Channels()
    channels_list = channels.get_channels_list(visible_filter=False)
    header_unity = get_header_unity(
        session.get_service(channels_list[channelKey]['serviceid']))
    header = get_header(
        session.get_service(channels_list[channelKey]['serviceid']))

    if 'serviceid' not in channels_list[channelKey] or len(
            channels_list[channelKey]['serviceid']) == 0:
        xbmcgui.Dialog().notification(
            'Sledování O2TV',
            'Pravděpodobně neaktivní kanál. Zkuste reset kanálů.',
            xbmcgui.NOTIFICATION_ERROR, 5000)
        sys.exit()

    subscription = session.get_service(
        channels_list[channelKey]['serviceid'])['subscription']

    if addon.getSetting('select_resolution') == 'true' and addon.getSetting(
            'stream_type') == 'HLS' and addon.getSetting('only_sd') != 'true':
        resolution = xbmcgui.Dialog().select('Rozlišení', ['HD', 'SD'],
                                             preselect=0)
    else:
        resolution = -1

    if addon.getSetting('stream_type') == 'MPEG-DASH':
        stream_type = 'DASH'
    else:
        stream_type = 'HLS'

    force_mpeg_dash = 0
    if addon.getSetting('stream_type') == 'HLS' and xbmc.getCondVisibility(
            'System.HasAddon(inputstream.adaptive)') and (
                type == 'live_iptv' or type == 'live_iptv_epg'
            ) and addon.getSetting('force_mpeg_dash') == 'true':
        stream_type = 'DASH'
        force_mpeg_dash = 1

    if type == 'live' or type == 'live_iptv' or type == 'live_iptv_epg':
        startts = 0
        channels_details = get_epg_live(len(channels_list.keys()))
        if channels_list[channelKey]['name'] in channels_details:
            without_details = 0
        else:
            without_details = 1

        if channelKey in channels_list and without_details == 0:
            data = channels_details[channels_list[channelKey]['name']]
            start = data['start']
            startts = int(time.mktime(start.timetuple()))
            end = data['end']
            epgId = str(data['epgId'])

    if addon.getSetting('stream_type') == 'MPEG-DASH-web':
        if type == 'archiv' or type == 'archiv_iptv':
            data = call_o2_api(
                url='https://api.o2tv.cz/unity/api/v1/programs/' + str(epgId) +
                '/playlist/',
                data=None,
                header=header_unity)
        if type == 'live' or type == 'live_iptv' or type == 'live_iptv_epg':
            data = call_o2_api(
                url=
                'https://api.o2tv.cz/unity/api/v1/channels/playlist/?channelKey='
                + quote(channelKey),
                data=None,
                header=header_unity)
        if type == 'recording':
            data = call_o2_api(
                url='https://api.o2tv.cz/unity/api/v1/recordings/' +
                str(epgId) + '/playlist/',
                data=None,
                header=header_unity)
        if 'err' in data:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s přehráním streamu',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()
        if 'playlist' in data and len(
                data['playlist']) > 0 and 'streamUrls' in data['playlist'][
                    0] and 'main' in data['playlist'][0]['streamUrls'] and len(
                        data['playlist'][0]['streamUrls']['main']) > 0:
            if 'timeshift' in data['playlist'][0]['streamUrls']:
                url = data['playlist'][0]['streamUrls']['timeshift']
            else:
                url = data['playlist'][0]['streamUrls']['main']
            request = Request(url=url, data=None, headers=header)
            response = urlopen(request)
            url = response.geturl()
        else:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s přehráním streamu',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()
    else:
        if type == 'archiv' or type == 'archiv_iptv':
            start = int(float(start) * 1000)
            end = int(float(end) * 1000)
            post = {
                'serviceType':
                'TIMESHIFT_TV',
                'deviceType':
                addon.getSetting('devicetype'),
                'streamingProtocol':
                stream_type,
                'subscriptionCode':
                subscription,
                'channelKey':
                encode(channelKey),
                'fromTimestamp':
                str(start),
                'toTimestamp':
                str(end + (int(addon.getSetting('offset')) * 60 * 1000)),
                'id':
                epgId,
                'encryptionType':
                'NONE'
            }
        if type == 'live' or type == 'live_iptv' or type == 'live_iptv_epg':
            if (addon.getSetting('stream_type') == 'MPEG-DASH'
                    or force_mpeg_dash == 1
                ) and startts > 0 and addon.getSetting('startover') == 'true':
                startts = int(float(startts) * 1000 - 300000)
                post = {
                    'serviceType': 'STARTOVER_TV',
                    'deviceType': addon.getSetting('devicetype'),
                    'streamingProtocol': stream_type,
                    'subscriptionCode': subscription,
                    'channelKey': encode(channelKey),
                    'fromTimestamp': startts,
                    'encryptionType': 'NONE'
                }
            else:
                post = {
                    'serviceType': 'LIVE_TV',
                    'deviceType': addon.getSetting('devicetype'),
                    'streamingProtocol': stream_type,
                    'subscriptionCode': subscription,
                    'channelKey': encode(channelKey),
                    'encryptionType': 'NONE'
                }
        if type == 'recording':
            post = {
                'serviceType': 'NPVR',
                'deviceType': addon.getSetting('devicetype'),
                'streamingProtocol': stream_type,
                'subscriptionCode': subscription,
                'contentId': epgId,
                'encryptionType': 'NONE'
            }
        if addon.getSetting(
                'stream_type') != 'MPEG-DASH' and force_mpeg_dash == 0 and (
                    addon.getSetting('only_sd') == 'true' or resolution == 1):
            post.update({'resolution': 'SD'})
        data = call_o2_api(
            url='https://app.o2tv.cz/sws/server/streaming/uris.json',
            data=post,
            header=header)
        if 'err' in data:
            if data['err'] == 'Not Found':
                post = {
                    'serviceType': 'LIVE_TV',
                    'deviceType': addon.getSetting('devicetype'),
                    'streamingProtocol': stream_type,
                    'subscriptionCode': subscription,
                    'channelKey': encode(channelKey),
                    'encryptionType': 'NONE'
                }
                data = call_o2_api(
                    url='https://app.o2tv.cz/sws/server/streaming/uris.json',
                    data=post,
                    header=header)
                if 'err' in data:
                    xbmcgui.Dialog().notification(
                        'Sledování O2TV', 'Problém s přehráním streamu',
                        xbmcgui.NOTIFICATION_ERROR, 5000)
                    sys.exit()
            else:
                xbmcgui.Dialog().notification('Sledování O2TV',
                                              'Problém s přehráním streamu',
                                              xbmcgui.NOTIFICATION_ERROR, 5000)
                sys.exit()
        url = ''
        if 'uris' in data and len(
                data['uris']) > 0 and 'uri' in data['uris'][0] and len(
                    data['uris'][0]['uri']) > 0:
            for uris in data['uris']:
                print(uris)
                if addon.getSetting(
                        'only_sd'
                ) != 'true' and resolution != 1 and uris['resolution'] == 'HD':
                    url = uris['uri']
                if (addon.getSetting('only_sd') == 'true'
                        or resolution == 1) and uris['resolution'] == 'SD':
                    url = uris['uri']
            if url == '':
                url = data['uris'][0]['uri']
            if addon.getSetting(
                    'stream_type') == 'MPEG-DASH' or force_mpeg_dash == 1:
                request = Request(url=url, data=None, headers=header)
                response = urlopen(request)
                url = response.geturl().replace('http:', 'https:').replace(
                    ':80/', ':443/')
        else:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s přehráním streamu',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()

    if type == 'live_iptv' or type == 'live_iptv_epg':
        list_item = xbmcgui.ListItem(path=url)
        list_item = get_listitem_epg_details(list_item,
                                             str(epgId),
                                             '',
                                             update_from_api=1)
    elif type == 'archiv_iptv':
        list_item = xbmcgui.ListItem(title)
        list_item = get_listitem_epg_details(list_item,
                                             str(epgId),
                                             '',
                                             update_from_api=1)
    else:
        list_item = xbmcgui.ListItem(path=url)

    if addon.getSetting('stream_type') == 'MPEG-DASH' or addon.getSetting(
            'stream_type') == 'MPEG-DASH-web' or force_mpeg_dash == 1:
        list_item.setProperty('inputstreamaddon', 'inputstream.adaptive')
        list_item.setProperty('inputstream', 'inputstream.adaptive')
        list_item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
        list_item.setMimeType('application/dash+xml')
    if type == 'archiv_iptv' or (type == 'live_iptv' and
                                 (addon.getSetting('stream_type') != 'HLS'
                                  or force_mpeg_dash == 1)
                                 and addon.getSetting('startover')
                                 == 'true') or type == 'live_iptv_epg':
        playlist = xbmc.PlayList(1)
        playlist.clear()
        if epgId is not None:
            event = get_epg_details([str(epgId)], update_from_api=1)
            list_item.setInfo('video', {'title': event['title']})
        else:
            list_item.setInfo('video',
                              {'title': channels_list[channelKey]['name']})
        xbmc.PlayList(1).add(url, list_item)
        xbmc.Player().play(playlist)
    else:
        list_item.setContentLookup(False)
        xbmcplugin.setResolvedUrl(_handle, True, list_item)