Ejemplo n.º 1
0
def list_devices(label):
    xbmcplugin.setPluginCategory(_handle, label)
    session = Session()
    for serviceid in session.get_services():
        data = call_o2_api(url='https://api.o2tv.cz/unity/api/v1/devices/',
                           data=None,
                           header=get_header_unity(
                               session.services[serviceid]))
        if 'err' in data:
            xbmcgui.Dialog().notification(
                'Sledování O2TV',
                'Problém při zjištování spárovaných zařízení',
                xbmcgui.NOTIFICATION_ERROR, 4000)
            sys.exit()
        if 'pairedDeviceAddLimit' in data and 'sessionLimit' in data and 'result' in data:
            list_item = xbmcgui.ListItem(
                label='Limit souběžných přehrávání: ' +
                str(int(data['sessionLimit'])))
            xbmcplugin.addDirectoryItem(_handle, None, list_item, False)
        else:
            xbmcgui.Dialog().notification(
                'Sledování O2TV',
                'Problém při zjištování spárovaných zařízení',
                xbmcgui.NOTIFICATION_ERROR, 4000)
            sys.exit()

        data = call_o2_api(
            url=
            'https://app.o2tv.cz/sws/subscription/settings/subscription-configuration.json',
            data=None,
            header=get_header(session.services[serviceid]))
        if 'err' in data:
            xbmcgui.Dialog().notification(
                'Sledování O2TV',
                'Problém při zjištování spárovaných zařízení',
                xbmcgui.NOTIFICATION_ERROR, 4000)
            sys.exit()
        if 'pairedDevicesLimit' in data and 'pairedDevices' in data:
            list_item = xbmcgui.ListItem(label='Spárovaných zařízení: ' +
                                         str(len(data['pairedDevices'])) +
                                         '/' +
                                         str(int(data['pairedDevicesLimit'])))
            xbmcplugin.addDirectoryItem(_handle, None, list_item, False)
            if len(data['pairedDevices']) > 0:
                devices = sorted(data['pairedDevices'],
                                 key=lambda k: k['lastLoginTimestamp'])
                for device in devices:
                    list_item = xbmcgui.ListItem(
                        label=device['deviceName'] + ' (' +
                        str(device['deviceId']) + ') - ' +
                        datetime.fromtimestamp(device['lastLoginTimestamp'] /
                                               1000).strftime('%d.%m.%Y') +
                        ' z ' + device['lastLoginIpAddress'])
                    list_item.addContextMenuItems([(
                        'Smazat zařízení',
                        'RunPlugin(plugin://' + plugin_id +
                        '?action=unpair_device&deviceId=' +
                        quote(encode(str(device['deviceId']))) +
                        '&deviceName=' + quote(encode(device['deviceName'])) +
                        '&serviceid=' + serviceid + ')',
                    )])
                    xbmcplugin.addDirectoryItem(_handle, None, list_item,
                                                False)
        else:
            xbmcgui.Dialog().notification(
                'Sledování O2TV',
                'Problém při zjištování spárovaných zařízení',
                xbmcgui.NOTIFICATION_ERROR, 4000)
            sys.exit()
    xbmcplugin.endOfDirectory(_handle, cacheToDisc=False)
Ejemplo n.º 2
0
    def get_o2_channels(self):
        addon = xbmcaddon.Addon()
        channels = {}
        data = call_o2_api(url='https://api.o2tv.cz/unity/api/v1/channels/',
                           data=None,
                           header=get_header_unity())
        if 'err' in data:
            xbmcgui.Dialog().notification('O2TV',
                                          'Problém při načtení kanálů z O2',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()
        if 'result' in data and len(data['result']) > 0:
            for channel in data['result']:
                channels.update({
                    channel['channel']['channelKey']: {
                        'name':
                        channel['channel']['name'],
                        'number':
                        int(channel['channel']['weight']),
                        'logo':
                        'https://assets.o2tv.cz' +
                        channel['channel']['images']['color']['url'],
                        'key':
                        channel['channel']['keyForCache'],
                        'available':
                        False,
                        'serviceid':
                        ''
                    }
                })

        session = Session()
        for serviceid in session.get_services():
            for offer in session.services[serviceid]['offers']:
                post = {
                    'locality': session.services[serviceid]['locality'],
                    'tariff': session.services[serviceid]['tariff'],
                    'isp': session.services[serviceid]['isp'],
                    'language': 'ces',
                    'deviceType': addon.getSetting('devicetype'),
                    'liveTvStreamingProtocol': 'HLS',
                    'offer': offer
                }
                data = call_o2_api(
                    url='https://app.o2tv.cz/sws/server/tv/channels.json',
                    data=post,
                    header=get_header(session.services[serviceid]))
                if 'err' in data:
                    xbmcgui.Dialog().notification('Sledování O2TV',
                                                  'Problém s načtením kanálů',
                                                  xbmcgui.NOTIFICATION_ERROR,
                                                  5000)
                    sys.exit()
                if 'channels' in data and len(data['channels']) > 0:
                    for channel in data['channels']:
                        if data['channels'][channel][
                                'channelType'] == 'TV' and data['channels'][
                                    channel]['channelKey'] not in channels:
                            channels.update({
                                data['channels'][channel]['channelKey']: {
                                    'name':
                                    data['channels'][channel]['channelName'],
                                    'number':
                                    int(data['channels'][channel]
                                        ['channelNumber']),
                                    'key':
                                    '',
                                    'logo':
                                    ''
                                }
                            })
                        if data['channels'][channel]['channelKey'] in channels:
                            channels[data['channels'][channel]
                                     ['channelKey']].update(
                                         {'available': True})
                            if 'serviceid' not in channels[data['channels'][
                                    channel]['channelKey']] or len(
                                        channels[data['channels'][channel][
                                            'channelKey']]['serviceid']) == 0:
                                channels[data['channels'][channel]
                                         ['channelKey']].update(
                                             {'serviceid': serviceid})
        return channels
def get_event(epgId, pvrProgramId, title):
    addon = xbmcaddon.Addon()
    err = 0
    url = ''
    post = {}
    channelKey = ''
    stream_type = 'HLS'
    current_ts = int(time.mktime(datetime.now().timetuple()))
    event = get_epg_details([epgId], update_from_api=1)
    channels = Channels()
    channels_list = channels.get_channels_list('name', visible_filter=False)

    if event != None and (current_ts < event['availableTo']
                          or pvrProgramId is not None):
        if event['startTime'] < current_ts:
            if event['endTime'] < current_ts:
                if pvrProgramId == None:
                    channelKey = channels_list[event['channel']]['channelKey']
                    session = Session()
                    channels_list = channels.get_channels_list(
                        visible_filter=False)
                    header = get_header(
                        session.get_service(
                            channels_list[channelKey]['serviceid']))
                    subscription = session.get_service(
                        channels_list[channelKey]['serviceid'])['subscription']
                    post = {
                        'serviceType':
                        'TIMESHIFT_TV',
                        'deviceType':
                        addon.getSetting('devicetype'),
                        'streamingProtocol':
                        stream_type,
                        'subscriptionCode':
                        subscription,
                        'channelKey':
                        encode(channelKey),
                        'fromTimestamp':
                        str(event['startTime'] * 1000),
                        'toTimestamp':
                        str(event['endTime'] * 1000 +
                            (int(addon.getSetting('offset')) * 60 * 1000)),
                        'id':
                        epgId,
                        'encryptionType':
                        'NONE'
                    }
                else:
                    session = Session()
                    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['pvrProgramId'] == pvrProgramId:
                                    channelKey = program['program'][
                                        'channelKey']
                    if len(channelKey) > 0:
                        channels_list = channels.get_channels_list(
                            visible_filter=False)
                        header = get_header(
                            session.get_service(
                                channels_list[channelKey]['serviceid']))
                        subscription = session.get_service(
                            channels_list[channelKey]
                            ['serviceid'])['subscription']
                        post = {
                            'serviceType': 'NPVR',
                            'deviceType': addon.getSetting('devicetype'),
                            'streamingProtocol': stream_type,
                            'subscriptionCode': subscription,
                            'contentId': pvrProgramId,
                            'encryptionType': 'NONE'
                        }
            else:
                xbmc.log('live')
                err = 1
        else:
            xbmc.log('future')
            err = 1
    else:
        xbmc.log('neni')
        err = 1

    if err == 1:
        xbmcgui.Dialog().notification('Sledování O2TV',
                                      'Problém s stažením ' + encode(title),
                                      xbmcgui.NOTIFICATION_ERROR, 5000)
        current_ts = int(time.mktime(datetime.now().timetuple()))
        db.execute(
            'UPDATE queue SET status = -1, downloadts = ? WHERE epgId = ?',
            [str(current_ts), str(epgId)])
        db.commit()
        return {}, ''
    else:
        if addon.getSetting('only_sd') == 'true':
            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:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s stažením streamu',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
        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']:
                if addon.getSetting(
                        'only_sd') != 'true' and uris['resolution'] == 'HD':
                    url = uris['uri']
                if addon.getSetting(
                        'only_sd') == 'true' and uris['resolution'] == 'SD':
                    url = uris['uri']
            if url == '':
                url = data['uris'][0]['uri']
        else:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s stažením streamu',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
        return event, url
Ejemplo n.º 4
0
 def get_subscription(self, access_token, refresh_token, expires_in,
                      service_id, service_description):
     addon = xbmcaddon.Addon()
     header = get_header()
     header.update({
         'X-NanguTv-Access-Token': str(access_token),
         'X-NanguTv-Device-Id': addon.getSetting('deviceid')
     })
     data = call_o2_api(
         url=
         'https://app.o2tv.cz/sws/subscription/settings/subscription-configuration.json',
         data=None,
         header=header)
     if 'err' in data:
         xbmcgui.Dialog().notification(
             'Sledování O2TV', 'Problém při přihlášení - subskripce',
             xbmcgui.NOTIFICATION_ERROR, 5000)
         sys.exit()
     if 'isp' in data and len(
             data['isp']) > 0 and 'locality' in data and len(
                 data['locality']) > 0 and 'billingParams' in data and len(
                     data['billingParams']
                 ) > 0 and 'offers' in data['billingParams'] and len(
                     data['billingParams']['offers']
                 ) > 0 and 'tariff' in data['billingParams'] and len(
                     data['billingParams']['tariff']) > 0:
         subscription = data['subscription']
         isp = data['isp']
         locality = data['locality']
         offers = data['billingParams']['offers']
         tariff = data['billingParams']['tariff']
         header_unity = get_header_unity()
         header_unity.update({
             'x-o2tv-access-token':
             str(access_token),
             'x-o2tv-device-id':
             addon.getSetting('deviceid'),
             'x-o2tv-device-name':
             addon.getSetting('devicename')
         })
         data = call_o2_api(
             url='https://api.o2tv.cz/unity/api/v1/user/profile/',
             data=None,
             header=header_unity)
         if 'err' in data:
             xbmcgui.Dialog().notification(
                 'Sledování O2TV', 'Problém při přihlášení - profil',
                 xbmcgui.NOTIFICATION_ERROR, 5000)
             sys.exit()
         sdata = data['sdata']
         encodedChannels = data['encodedChannels']
         channels = data['ottChannels']['live']
         self.valid_to = int(time.time()) + 60 * 60 * 24 * 7
         self.services.update({
             service_id: {
                 'description': service_description,
                 'access_token': access_token,
                 'refresh_token': refresh_token,
                 'expires_in': expires_in,
                 'subscription': subscription,
                 'isp': isp,
                 'locality': locality,
                 'offers': offers,
                 'tariff': tariff,
                 'sdata': sdata,
                 'encodedChannels': encodedChannels,
                 'channels': channels
             }
         })
     else:
         xbmcgui.Dialog().notification(
             'Sledování O2TV', 'Problém s příhlášením - subskribce',
             xbmcgui.NOTIFICATION_ERROR, 5000)
         sys.exit()
Ejemplo n.º 5
0
    def get_auth_token(self):
        addon = xbmcaddon.Addon()
        self.services = {}
        post = {
            'username': addon.getSetting('username'),
            'password': addon.getSetting('password')
        }
        data = call_o2_api(
            url='https://ottmediator.o2tv.cz/ottmediator-war/login',
            data=post,
            header=get_header())
        if 'err' in data:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém při přihlášení',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()

        if 'services' in data and 'remote_access_token' in data and len(
                data['remote_access_token']) > 0 and len(data['services']) > 0:
            remote_access_token = data['remote_access_token']
            for service in data['services']:
                service_id = service['service_id']
                service_desc = service['description']

                post = {
                    'service_id': service_id,
                    'remote_access_token': remote_access_token
                }
                data = call_o2_api(
                    url=
                    'https://ottmediator.o2tv.cz/ottmediator-war/loginChoiceService',
                    data=post,
                    header=get_header())
                if 'err' in data:
                    pass
                    # xbmcgui.Dialog().notification('Sledování O2TV','Problém při přihlášení', xbmcgui.NOTIFICATION_ERROR, 5000)
                else:
                    post = {
                        'grant_type': 'remote_access_token',
                        'client_id': 'tef-web-portal-etnetera',
                        'client_secret': '2b16ac9984cd60dd0154f779ef200679',
                        'platform_id': '231a7d6678d00c65f6f3b2aaa699a0d0',
                        'language': 'cs',
                        'remote_access_token': str(remote_access_token),
                        'authority': 'tef-sso',
                        'isp_id': '1'
                    }
                    data = call_o2_api(url='https://oauth.o2tv.cz/oauth/token',
                                       data=post,
                                       header=get_header())
                    if 'err' in data:
                        xbmcgui.Dialog().notification(
                            'Sledování O2TV', 'Problém při přihlášení - token',
                            xbmcgui.NOTIFICATION_ERROR, 5000)
                    else:
                        if 'access_token' in data and len(
                                data['access_token']) > 0:
                            access_token = data['access_token']
                            refresh_token = data['refresh_token']
                            expires_in = 0
                            self.get_subscription(access_token, refresh_token,
                                                  expires_in, service_id,
                                                  service_desc)
                        else:
                            xbmcgui.Dialog().notification(
                                'Sledování O2TV',
                                'Problém s příhlášením - token',
                                xbmcgui.NOTIFICATION_ERROR, 5000)
        else:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s příhlášením',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
            sys.exit()
        if len(self.services) < 1:
            xbmcgui.Dialog().notification('Sledování O2TV',
                                          'Problém s příhlášením - služby',
                                          xbmcgui.NOTIFICATION_ERROR, 5000)
Ejemplo n.º 6
0
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)