コード例 #1
0
 def canali_live_play(self, guid):
     res = self.med.OttieniLiveStream(guid)
     infos = {}
     arts = {}
     title = ''
     if 'currentListing' in res[0]:
         self.__imposta_tipo_media(res[0]['currentListing']['program'])
         infos = _gather_info(res[0]['currentListing'])
         arts = _gather_art(res[0]['currentListing']['program'])
         title = ' - ' + infos['title']
     if 'tuningInstruction' in res[0]:
         data = {'mode': 'live'}
         vdata = res[0]['tuningInstruction']['urn:theplatform:tv:location:any']
         for v in vdata:
             if v['format'] == 'application/x-mpegURL':
                 data['id'] = v['releasePids'][0]
             else:
                 data['mid'] = v['releasePids'][0]
         kodiutils.addListItem(kodiutils.LANGUAGE(32137) + title, data, videoInfo=infos,
                               arts=arts, isFolder=False)
     if ('currentListing' in res[0] and
             res[0]['currentListing']['mediasetlisting$restartAllowed']):
         url = res[0]['currentListing']['restartUrl']
         vid = url.rpartition('/')[-1]
         kodiutils.addListItem(kodiutils.LANGUAGE(32138) + title, {'mode': 'video', 'pid': vid},
                               videoInfo=infos, arts=arts, isFolder=False)
     kodiutils.endScript()
コード例 #2
0
 def guida_tv_canale_giorno(self, cid, dt):
     res = self.med.OttieniGuidaTV(
         cid, dt, dt + 86399999)  # 86399999 is one day minus 1 ms
     kodiutils.setContent('videos')
     if 'listings' in res:
         for el in res['listings']:
             program = el['program'] if 'program' in el else {}
             if (kodiutils.getSettingAsBool('fullguide')
                     or ('mediasetprogram$hasVod' in program
                         and program['mediasetprogram$hasVod'])):
                 infos = _gather_info(el)
                 arts = _gather_art(el)
                 s_time = staticutils.get_date_from_timestamp(
                     el['startTime']).strftime("%H:%M")
                 e_time = staticutils.get_date_from_timestamp(
                     el['endTime']).strftime("%H:%M")
                 s = "{s}-{e} - {t}".format(
                     s=s_time,
                     e=e_time,
                     t=el['mediasetlisting$epgTitle'].encode('utf8'))
                 kodiutils.addListItem(s, {
                     'mode': 'video',
                     'guid': program['guid']
                 },
                                       videoInfo=infos,
                                       arts=arts,
                                       properties={
                                           'ResumeTime': '0.0',
                                           'TotalTime': '0.0',
                                           'StartOffset': '0.0'
                                       },
                                       isFolder=False)
     kodiutils.endScript()
コード例 #3
0
 def guida_tv_root(self):
     kodiutils.setContent('videos')
     els = self.med.OttieniCanaliLive(sort='ShortTitle', range=self.__imposta_range())
     for prog in els:
         infos = _gather_info(prog)
         arts = _gather_art(prog)
         if 'tuningInstruction' in prog:
             if prog['tuningInstruction'] and not prog['mediasetstation$eventBased']:
                 kodiutils.addListItem(prog["title"],
                                       {'mode': 'guida_tv', 'id': prog['callSign'],
                                        'week': staticutils.get_timestamp_midnight()},
                                       videoInfo=infos, arts=arts)
     kodiutils.endScript()
コード例 #4
0
 def __analizza_elenco(self, progs, setcontent=False, titlewd=False):
     if not progs:
         return
     if setcontent:
         self.__imposta_tipo_media(progs[0])
     for prog in progs:
         infos = _gather_info(prog, titlewd=titlewd)
         arts = _gather_art(prog)
         if 'media' in prog:
             # salta se non ha un media ma ha il tag perchè non riproducibile
             if prog['media']:
                 media = prog['media'][0]
                 args = {'mode': 'video'}
                 if 'pid' in media:
                     args['pid'] = media['pid']
                 elif 'publicUrl' in media:
                     args['pid'] = media['publicUrl'].split('/')[-1]
                 kodiutils.addListItem(infos["title"], args,
                                       videoInfo=infos, arts=arts, isFolder=False)
         elif 'tuningInstruction' in prog:
             data = {'mode': 'live'}
             if prog['tuningInstruction'] and not prog['mediasetstation$eventBased']:
                 vdata = prog['tuningInstruction']['urn:theplatform:tv:location:any']
                 for v in vdata:
                     if v['format'] == 'application/x-mpegURL':
                         data['id'] = v['releasePids'][0]
                     else:
                         data['mid'] = v['releasePids'][0]
                 kodiutils.addListItem(prog["title"], data, videoInfo=infos,
                                       arts=arts, isFolder=False)
         elif 'mediasetprogram$subBrandId' in prog:
             kodiutils.addListItem(prog["description"],
                                   {'mode': 'programma',
                                    'sub_brand_id': prog['mediasetprogram$subBrandId']},
                                   videoInfo=infos, arts=arts)
         elif 'mediasettvseason$brandId' in prog:
             kodiutils.addListItem(prog["title"],
                                   {'mode': 'programma',
                                    'brand_id': prog['mediasettvseason$brandId']},
                                   videoInfo=infos, arts=arts)
         elif 'seriesId' in prog:
             kodiutils.addListItem(prog["title"],
                                   {'mode': 'programma', 'series_id': prog['seriesId'],
                                    'title': prog['title']},
                                   videoInfo=infos, arts=arts)
         else:
             kodiutils.addListItem(prog["title"],
                                   {'mode': 'programma',
                                    'brand_id': prog['mediasetprogram$brandId']},
                                   videoInfo=infos, arts=arts)
コード例 #5
0
 def canali_live_root(self):
     kodiutils.setContent('videos')
     now = staticutils.get_timestamp()
     els = self.med.OttieniProgrammiLive()  # (sort='title')
     chans = {}
     for chan in els:
         if 'listings' in chan and chan['listings']:
             for prog in chan['listings']:
                 if prog['startTime'] <= now <= prog['endTime']:
                     guid = chan['guid']
                     chans[guid] = {'title': '{} - {}'.format(chan['title'],
                                                              kodiutils.py2_encode(
                                                                  prog["mediasetlisting$epgTitle"])),
                                    'infos': _gather_info(prog),
                                    'arts': _gather_art(prog),
                                    'restartAllowed': prog['mediasetlisting$restartAllowed']}
     els = self.med.OttieniCanaliLive(sort='ShortTitle')
     for prog in els:
         if (prog['callSign'] in chans and 'tuningInstruction' in prog and
                 prog['tuningInstruction'] and not prog['mediasetstation$eventBased']):
             chn = chans[prog['callSign']]
             if chn['arts'] == {}:
                 chn['arts'] = _gather_art(prog)
             if chn['restartAllowed']:
                 if kodiutils.getSettingAsBool('splitlive'):
                     kodiutils.addListItem(chn['title'], {'mode': 'live',
                                                          'guid': prog['callSign']},
                                           videoInfo=chn['infos'], arts=chn['arts'])
                     continue
                 vid = self.__ottieni_vid_restart(prog['callSign'])
                 if vid:
                     kodiutils.addListItem(chn['title'], {'mode': 'video', 'pid': vid},
                                           videoInfo=chn['infos'], arts=chn['arts'],
                                           isFolder=False)
                     continue
             data = {'mode': 'live'}
             vdata = prog['tuningInstruction']['urn:theplatform:tv:location:any']
             for v in vdata:
                 if v['format'] == 'application/x-mpegURL':
                     data['id'] = v['releasePids'][0]
                 else:
                     data['mid'] = v['releasePids'][0]
             kodiutils.addListItem(chn['title'], data,
                                   videoInfo=chn['infos'], arts=chn['arts'], isFolder=False)
     kodiutils.endScript()
コード例 #6
0
 def guida_tv_canale_giorno(self, cid, dt):
     res = self.med.OttieniGuidaTV(cid, dt, dt + 86399999)  # 86399999 is one day minus 1 ms
     if 'listings' in res:
         for el in res['listings']:
             if (kodiutils.getSettingAsBool('fullguide') or
                     ('mediasetprogram$hasVod' in el['program'] and
                      el['program']['mediasetprogram$hasVod'])):
                 infos = _gather_info(el)
                 arts = _gather_art(el)
                 s_time = staticutils.get_date_from_timestamp(
                     el['startTime']).strftime("%H:%M")
                 e_time = staticutils.get_date_from_timestamp(
                     el['endTime']).strftime("%H:%M")
                 s = "{s}-{e} - {t}".format(s=s_time, e=e_time,
                                            t=el['mediasetlisting$epgTitle'])
                 kodiutils.addListItem(s,
                                       {'mode': 'video', 'guid': el['program']['guid']},
                                       videoInfo=infos, arts=arts, isFolder=False)
     kodiutils.endScript()
コード例 #7
0
 def canali_live_play(self, guid):
     res = self.med.OttieniLiveStream(guid)
     infos = {}
     arts = {}
     title = ''
     if 'currentListing' in res[0]:
         listing = res[0]['currentListing']
         program = listing['program'] if 'program' in listing else {}
         self.__imposta_tipo_media(program)
         infos = _gather_info(listing)
         arts = _gather_art(program)
         title = program['title'] if 'title' in program else infos['title']
         title = kodiutils.py2_decode(title)
     if 'tuningInstruction' in res[0]:
         data = {'mode': 'live'}
         vdata = res[0]['tuningInstruction'][
             'urn:theplatform:tv:location:any']
         for v in vdata:
             if v['format'] == 'application/x-mpegURL':
                 data['id'] = v['releasePids'][0]
             else:
                 data['mid'] = v['releasePids'][0]
         infos['title'] = kodiutils.LANGUAGE(32137) + ' - ' + title
         kodiutils.addListItem(infos['title'],
                               data,
                               videoInfo=infos,
                               arts=arts,
                               properties={'ResumeTime': '0.0'},
                               isFolder=False)
     if ('currentListing' in res[0] and
             res[0]['currentListing']['mediasetlisting$restartAllowed']):
         url = res[0]['currentListing']['restartUrl']
         vid = url.rpartition('/')[-1]
         infos['title'] = kodiutils.LANGUAGE(32138) + ' - ' + title
         kodiutils.addListItem(infos['title'], {
             'mode': 'video',
             'pid': vid
         },
                               videoInfo=infos,
                               arts=arts,
                               properties={'ResumeTime': '0.0'},
                               isFolder=False)
     kodiutils.endScript()
コード例 #8
0
 def __analizza_elenco(self,
                       progs,
                       setcontent=False,
                       titlewd=False,
                       isDeletable=False,
                       delete_list='',
                       context_ui=''):
     if not progs:
         return
     if setcontent:
         self.__imposta_tipo_media(progs[0])
     defaultArt = self.__getDirectoryArt()
     for prog in progs:
         infos = _gather_info(prog,
                              titlewd=titlewd,
                              lookup_fullplot=self.lookup_fullplot)
         arts = _gather_art(prog) or defaultArt
         kodiutils.log('__analizza_elenco infos: {}'.format(infos))
         kodiutils.log('__analizza_elenco arts: {}'.format(arts))
         item_id = ''
         guid = ''
         args = {}
         properties = {}
         if 'media' in prog:
             kodiutils.log('__analizza_elenco media: {}'.format(str(prog)),
                           4)
             args['mode'] = 'video'
             # salta se non ha un media ma ha il tag perchè non riproducibile
             if prog['media']:
                 media = prog['media'][0]
                 if 'position' in prog:
                     args['offset'] = prog['position']
                 if 'pid' in media:
                     args['pid'] = media['pid']
                 elif 'publicUrl' in media:
                     args['pid'] = media['publicUrl'].split('/')[-1]
                 if 'guid' in media:
                     args['guid'] = media['guid']
                     guid = media['guid']
                 if 'mediasetprogram$duration' in prog:
                     properties['TotalTime'] = str(
                         prog['mediasetprogram$duration'])
                 if 'mediasetprogram$brandId' in prog:
                     item_id = prog['mediasetprogram$brandId']
                 properties['ResumeTime'] = '0.0'
                 menuItems = self.menuItems(isDeletable=isDeletable,
                                            delete_list=delete_list,
                                            item_id=item_id,
                                            guid=guid,
                                            context_ui=context_ui)
                 kodiutils.addListItem(infos["title"],
                                       args,
                                       videoInfo=infos,
                                       arts=arts,
                                       isFolder=False,
                                       properties=properties,
                                       menuItems=menuItems)
         elif 'tuningInstruction' in prog:
             kodiutils.log(
                 '__analizza_elenco tuningInstruction: {}'.format(
                     str(prog)), 4)
             args['mode'] = 'live'
             if prog['tuningInstruction'] and not prog[
                     'mediasetstation$eventBased']:
                 vdata = prog['tuningInstruction'][
                     'urn:theplatform:tv:location:any']
                 for v in vdata:
                     if v['format'] == 'application/x-mpegURL':
                         args['id'] = v['releasePids'][0]
                     else:
                         args['mid'] = v['releasePids'][0]
                 kodiutils.addListItem(prog["title"],
                                       args,
                                       videoInfo=infos,
                                       arts=arts,
                                       isFolder=False)
         elif 'mediasetprogram$subBrandId' in prog:
             kodiutils.log(
                 '__analizza_elenco subBrandId: {}'.format(str(prog)), 4)
             item_id = prog['mediasetprogram$brandId'] if prog[
                 'mediasetprogram$brandId'] else ''
             args['mode'] = 'programma'
             args['sub_brand_id'] = prog['mediasetprogram$subBrandId']
             menuItems = self.menuItems(isDeletable=isDeletable,
                                        delete_list=delete_list,
                                        item_id=item_id,
                                        guid=guid,
                                        context_ui=context_ui)
             kodiutils.addListItem(infos["title"],
                                   args,
                                   videoInfo=infos,
                                   arts=arts,
                                   menuItems=menuItems)
         elif 'mediasettvseason$brandId' in prog:
             kodiutils.log(
                 '__analizza_elenco brandId: {}'.format(str(prog)), 4)
             # title = prog['title']
             # if 'mediasettvseason$displaySeason' in prog and  'mediasetprogram$seasonTitle' in prog:
             item_id = prog['mediasettvseason$brandId'] if prog[
                 'mediasettvseason$brandId'] else ''
             args['mode'] = 'programma'
             args['brand_id'] = prog['mediasettvseason$brandId']
             menuItems = self.menuItems(isDeletable=isDeletable,
                                        delete_list=delete_list,
                                        item_id=item_id,
                                        guid=guid,
                                        context_ui=context_ui)
             kodiutils.addListItem(prog["title"],
                                   args,
                                   videoInfo=infos,
                                   arts=arts,
                                   menuItems=menuItems)
         elif 'seriesId' in prog:
             kodiutils.log(
                 '__analizza_elenco seriesId: {}'.format(str(prog)), 4)
             title = prog['title']
             seriesTitle = prog['title']
             sort = 'tvSeasonNumber'
             order = 'asc'
             item_id = prog['mediasetprogram$brandId'] if prog[
                 'mediasetprogram$brandId'] else ''
             if 'mediasetprogram$pageUrl' in prog and 'programmi-tv' in str(
                     prog['mediasetprogram$pageUrl'].encode(
                         'utf-8')).lower():
                 if 'mediasetprogram$seasonTitle' in prog and 'mediasetprogram$displaySeason' in prog:
                     seasonTitle = str(
                         prog['mediasetprogram$seasonTitle'].encode(
                             'utf-8'))
                     # displaySeason = str(prog['mediasetprogram$displaySeason'].encode('utf-8'))
                     seriesTitle = seasonTitle
                     title = seriesTitle
             args['mode'] = 'programma'
             args['series_id'] = prog['seriesId']
             args['sort'] = sort
             args['order'] = order
             args['title'] = seriesTitle
             menuItems = self.menuItems(isDeletable=isDeletable,
                                        delete_list=delete_list,
                                        item_id=item_id,
                                        guid=guid,
                                        context_ui=context_ui)
             kodiutils.addListItem(title,
                                   args,
                                   videoInfo=infos,
                                   arts=arts,
                                   menuItems=menuItems)
         else:
             kodiutils.log('__analizza_elenco other: {}'.format(str(prog)),
                           4)
             item_id = prog['mediasetprogram$brandId'] if prog[
                 'mediasetprogram$brandId'] else ''
             args['mode'] = 'programma'
             args['brand_id'] = prog['mediasetprogram$brandId']
             menuItems = self.menuItems(isDeletable=isDeletable,
                                        delete_list=delete_list,
                                        item_id=item_id,
                                        guid=guid,
                                        context_ui=context_ui)
             kodiutils.addListItem(prog["title"],
                                   args,
                                   videoInfo=infos,
                                   arts=arts,
                                   menuItems=menuItems)