コード例 #1
0
 def _getShowsPage(self, url, page, hide_show_no_ep, channel):
   shows = nw.getResponseJson(url.format(page))
   if shows.isSucceeded:
     for show in shows.body['data']:
       episodes = 0
       channel_id = 0
       for ti in show['taxonomy_items']:
         if ti['type'] == 'show':
           episodes = ti['metadata']['episodes']
         elif ti['type'] == 'home-channel':
           channel_id = ti['term_id']
       if hide_show_no_ep == 'false' or episodes != '0':
         title = nw.getTranslation(30015).format(show = show['title'], number = episodes)
         img = show['image_data']
         self._addItem(title, { 'action' : 's', 'showid' : show['id'], 'channel' : channel_id }, self._getUrlImgPreview(img), self._findFanart(channel_id), show['description'])
     pages = shows.body['total_pages']
     page = int(page)
     if page < pages - 1:
       if xbmcplugin.getSetting(self._handle, 'use_pagination') == 'true':
         if channel != None:
           nw.createNextPageItem(self._handle, page + 2, { 'action' : 'p', 'page' : page + 1, 'channel' : channel })
         else:
           nw.createNextPageItem(self._handle, page + 2, { 'action' : 'p', 'page' : page + 1 })
         xbmcplugin.endOfDirectory(self._handle)
       else:
         self._getShowsPage(url, page + 1, hide_show_no_ep, channel)
     else:
       xbmcplugin.endOfDirectory(self._handle)
コード例 #2
0
  def __init__(self):

    if len(self._params) == 0: # Visualizzazione del menu.

      # Shows.
      title = nw.getTranslation(30000)
      li = nw.createListItem(title, streamtype = 'video', infolabels = { 'title' : title })
      xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'id' : 'a', 'page' : self._getLaCosaUrl('archivio') }), li, True)

      shows = nw.getResponseBS(self._getLaCosaUrl('rubriche'))
      if shows.isSucceeded:
        shows = shows.body.findAll('div', 'icon_programmi')
        for show in shows:
          title = show.h3.a.text
          li = nw.createListItem(title, thumbnailImage = show.img['src'], streamtype = 'video', infolabels = { 'title' : title, 'plot' : show.p.text })
          xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'id' : 's', 'page' : show.a['href'] }), li, True)

      xbmcplugin.endOfDirectory(self._handle)

      if shows == None or not shows:
        nw.showNotification(nw.getTranslation(30001)) # Errore recupero shows.

    else:

      response = nw.getResponseBS(self._params['page'])
      if response.isSucceeded:

        # Archivio.
        if self._params['id'] == 'a':
          videos = response.body.find('div', id='video-recenti').findAll('div', 'video-block')
          for video in videos:
            title = re.search('<a title="(.+?)"', video.renderContents())
            if title != None:
              title = nw.htmlDecode(title.group(1))
              time = self._getTime(video)
              self._setEpItem(video, title, time)

          if len(videos) > 0:
            nextPage = response.body.find('span', 'current')
            nextPage = nextPage.findNext('a')
            if nextPage.get('class') and nextPage['class'] == 'page-numbers':
              nw.createNextPageItem(self._handle, nextPage.text, { 'id' : 'a', 'page' : nextPage['href'] })
            xbmcplugin.endOfDirectory(self._handle)
          else:
            nw.showNotification(nw.getTranslation(30002)) # Errore recupero dei videos shows.

        # Videos.
        if self._params['id'] == 's': # Visualizzazione dei videos di uno show.
          videos = response.body.find('div', id='recenti_canale').findAll('li')
          for video in videos:
            title = video.h4.text
            time = self._getTime(video)
            self._setEpItem(video, title, time)

          if len(videos) > 0:
            xbmcplugin.endOfDirectory(self._handle)
          else:
            nw.showNotification(nw.getTranslation(30002)) # Errore recupero dei videos shows.

        # Play video.
        elif self._params['id'] == 'v':
          title = response.body.find('meta', { 'property' : 'og:title' })['content']
          img = response.body.find('meta', { 'property' : 'og:image' })['content']
          descr = response.body.find('meta', { 'property' : 'og:description' })['content']
          streams = response.body.find('iframe')
          if streams != None:
            response = nw.getResponseForRegEx(streams['src'])
            found_stream = None

            if response.isSucceeded:
              streams = re.findall('mp4_[0-9]+":"(.*?)",', response.body)
              if not streams:
                streams = re.search('hd_src_no_ratelimit":"(.+?)"', response.body)
                found_stream = streams.group(1).replace('\/', '/')
              if streams == None:
                streams = re.search('sd_src_no_ratelimit":"(.+?)"', response.body)
                found_stream = streams.group(1).replace('\/', '/')
              if streams == None:
                streams = re.search('hd_src":"(.+?)"', response.body)
                found_stream = streams.group(1).replace('\/', '/')
              if streams == None:
                streams = re.search('sd_src":"(.+?)"', response.body)
                found_stream = streams.group(1).replace('\/', '/')

              if found_stream == None:
                for stream in reversed(streams):
                  if stream != '':
                    found_stream = stream
                    break

            if found_stream is not None:
              nw.playStream(self._handle, title, img, found_stream, 'video', { 'title' : title, 'plot' : descr })
            else:
              nw.showVideoNotAvailable() # Video non disponibile.
          else:
            nw.showVideoNotAvailable() # Video non disponibile.
コード例 #3
0
  def __init__(self):

    if len(self._params) == 0: # Scelta tra Audio o Video

      nw.createAudioVideoItems(self._handle)

      # Show items.
      xbmcplugin.endOfDirectory(self._handle)

    elif len(self._params) == 1 and self._params['content_type'] == 'video': # Visualizzazione del menu video (diretta e video).
      qlty = int(xbmcplugin.getSetting(self._handle, 'vid_quality')) + 1
      streamParam = self._getStreamParam(qlty)
      if streamParam != None:
        response = self._getVirginResponse('/video')
        if response.isSucceeded:
          title = nw.getTranslation(30003)
          img = '{0}/resources/images/VirginRadioTV.png'.format(os.path.dirname(os.path.abspath(__file__)))
          li = nw.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title }) # Diretta.
          url = 'rtmp://{0}:1935/{1}/{2} app={1} playpath={2} swfUrl=http://video.virginradioitaly.it/com/universalmind/swf/video_player_102.swf?xmlPath=http://video.virginradioitaly.it/com/universalmind/tv/virgin/videoXML.xml&advXML=http://video.virginradioitaly.it/com/universalmind/adsWizzConfig/1.xml pageURL=http://www.virginradio.it swfVfy=true live=true timeout=30 flashVer=LNX 11,2,202,297'.format(streamParam[0], streamParam[1], streamParam[2])
          xbmcplugin.addDirectoryItem(self._handle, url, li, False)
          videos = response.body.findAll('div', 'anteprima_articolo article_cont vrg_article_preview_tree_medium')
          for video in videos:
            title = video.a.img['title']
            img = self._makeUrl(video.a.img['data-original']).replace('206/122', '600/315')
            descr = ''
            if video.h3 != None:
              descr = video.h3.a.text
            li = nw.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr }, isPlayable = True)
            url = nw.formatUrl({ 'id' : 'v', 'page' : video.a['href'].replace('http://www.virginradio.it', '') })
            xbmcplugin.addDirectoryItem(self._handle, url, li, False)

          nw.createNextPageItem(self._handle, 1, { 'id' : 'p', 'page' : 1 })

          # Show items.
          xbmcplugin.endOfDirectory(self._handle)

      if (streamParam == None or not streamParam) and (response == None or not response or not response.isSucceeded):
        nw.showNotification(nw.getTranslation(30004))

    elif len(self._params) == 1 and self._params['content_type'] == 'audio': # Visualizzazione delle web radio.
      response = self._getVirginResponse('/webradio')
      if response.isSucceeded:
        divs = response.body.findAll('div', { 'class' : re.compile('.+') })
        for div in divs:
          if div['class'].find('overbox_vrg_article_preview_webradio') > -1:
            radios = div.findAll('div', 'anteprima_articolo article_cont')
            for radio in radios:
              title = self._webradioRe.sub('', radio.a.img['title']).strip()
              img = self._makeImageUrl(radio.a.img['data-original'])
              li = nw.createListItem(title, thumbnailImage = img, streamtype = 'music', infolabels = { 'title' : title }, isPlayable = True)
              url = nw.formatUrl({ 'id' : 'r', 'page' : radio.a['href'].replace('http://www.virginradio.it', '') })
              xbmcplugin.addDirectoryItem(self._handle, url, li, False)
          elif div['class'].find('text_edit') > -1 and div['class'].find('vrg_box_title_webradio') > -1 and div['class'].find('last') > -1:
            break # Stops "for div in divs:".
        xbmcplugin.endOfDirectory(self._handle)

    elif self._params['id'] == 'p':
      response = self._getVirginResponse('/archivio/1099/video?sortElement=data_pubblicazione,true&page={0}'.format(self._params['page']))
      if response.isSucceeded:
        videos = response.body.findAll('div', 'anteprima_ricerca_archivio vrg_archive_results VRG')
        for video in videos:
          title = video.a.img['title']
          img = self._makeUrl(video.a.img['src']).replace('130/90', '600/315')
          descr = video.find('p', 'testo').a.text
          li = nw.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr }, isPlayable = True)
          url = nw.formatUrl({ 'id' : 'v', 'page' : video.a['href'].replace('http://www.virginradio.it', '') })
          xbmcplugin.addDirectoryItem(self._handle, url, li, False)

        if len(response.body.findAll('a', id='prossimi')) == 1:
          page = int(self._params['page']) + 1
          nw.createNextPageItem(self._handle, page, { 'id' : 'p', 'page' : page })

      xbmcplugin.endOfDirectory(self._handle)

    else:
      response = self._getVirginResponse(self._params['page'])
      if response.isSucceeded:

        # Riproduzione di un video.
        if self._params['id'] == 'v':
          title = response.body.find('meta', { 'property' : 'og:title' })['content']
          img = response.body.find('meta', { 'property' : 'og:image' })['content']
          descr = response.body.find('meta', { 'property' : 'og:description' })['content']
          play = response.body.find('a', 'player plain')
          if play == None:
            play = response.body.find('div', 'multimedia video')
            play = re.search('embed/(.+?)\\"', play.renderContents())
            if play == None:
              nw.showVideoNotAvailable()
            else:
              play = 'plugin://plugin.video.youtube/play/?video_id={0}'.format(play.group(1))
          else:
            server = re.search('netConnectionUrl: "rtmp://(.+?)/(.+?)/', response.body.renderContents())
            play = play['href']
            play = re.search('(.+?):(.+)', play)
            play = 'rtmp://{0}:1935/{1}/{2} app={1} playpath={3}:{2} pageURL=http://www.virginradio.it swfVfy=true live=false flashVer=LNX 10,1,82,76'.format(server.group(1), server.group(2), play.group(2), play.group(1))
          nw.playStream(self._handle, title, img, play, 'video', { 'title' : title, 'plot' : descr })

        # Riproduzione di una radio.
        elif self._params['id'] == 'r':
          stream = re.search("radioUrl_AdsWizz='(.+?)'", response.body.renderContents())
          if stream != None:
            title = self._webradioRe.sub('', response.body.find('meta', { 'property' : 'og:title' })['content']).strip()
            img = self._makeImageUrl(response.body.find('img', 'lazy')['data-original'])
            nw.playStream(self._handle, title, img, stream.group(1), 'music', { 'title' : title })
コード例 #4
0
  def __init__(self):

    # Audio, Video, Foto.
    if len(self._params) == 0:

      nw.createAudioVideoItems(self._handle, self._fanart)
      xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'content_type' : 'image' }), nw.createListItem(nw.getTranslation(30005), thumbnailImage = 'DefaultPicture.png', fanart = self._fanart), True)
      xbmcplugin.endOfDirectory(self._handle)

    elif 'content_type' in self._params:

      # Video.
      if self._params['content_type'] == 'video':
        qlty = int(xbmcplugin.getSetting(self._handle, 'vid_quality')) + 1
        streamParam = self._getStreamParam(qlty)
        if streamParam != None:
          title = nw.getTranslation(30003)
          img = '{0}/resources/images/VirginRadioTV.png'.format(os.path.dirname(os.path.abspath(__file__)))
          li = nw.createListItem(title, thumbnailImage = img, fanart = self._fanart, streamtype = 'video', infolabels = { 'title' : title }) # Diretta.
          url = 'rtmp://{0}:1935/{1}/{2} app={1} playpath={2} swfUrl=http://video.virginradioitaly.it/com/universalmind/swf/video_player_102.swf?xmlPath=http://video.virginradioitaly.it/com/universalmind/tv/virgin/videoXML.xml&advXML=http://video.virginradioitaly.it/com/universalmind/adsWizzConfig/1.xml pageURL=http://www.virginradio.it swfVfy=true live=true timeout=30 flashVer=LNX 11,2,202,297'.format(streamParam[0], streamParam[1], streamParam[2])
          xbmcplugin.addDirectoryItem(self._handle, url, li)

        page_num = 700
        addon_page = 2
        response = self._getVirginResponse('VideoList.jsp?x_pag={0}&page=1'.format(page_num))
        if response.isSucceeded:
          for video in response.body['videos']:
            li = self._setVideoListItem(video)

          nw.createNextPageItem(self._handle, addon_page, { 'action' : 'v', 'page' : page_num + 1, 'page_tot' : response.body['total'], 'addon_page' : addon_page + 1 }, self._fanart)

        xbmcplugin.endOfDirectory(self._handle)

        if (streamParam == None or not streamParam) or (response == None or not response or not response.isSucceeded):
          nw.showNotification(nw.getTranslation(30004))

      # Audio.
      elif self._params['content_type'] == 'audio':
        xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'r' }), nw.createListItem('Radio', thumbnailImage = 'DefaultFolder.png', fanart = self._fanart), True)
        xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'p' }), nw.createListItem('Podcast', thumbnailImage = 'DefaultFolder.png', fanart = self._fanart), True)
        xbmcplugin.endOfDirectory(self._handle)

      # Foto.
      elif self._params['content_type'] == 'image':
        response = self._getVirginResponse('GalleryList.jsp')
        if response.isSucceeded:
          response = self._getVirginResponse('GalleryList.jsp?thumbSize=1280x720&x_pag={0}'.format(response.body['total']))
          if response.isSucceeded:
            for gallery in response.body['gallery']:
              title = self._formatTitle(gallery)
              img = gallery['thumb']
              descr = self._formatDescr(gallery)
              li = nw.createListItem(title, thumbnailImage = img, fanart = self._fanart, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr })
              xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'f', 'id' : gallery['id'], 'fanart' : img }), li, True)
              
        xbmcplugin.endOfDirectory(self._handle)

    # Video - pagina o riproduzione.
    elif self._params['action'] == 'v':
      if 'id' in self._params:
        response = self._getVirginResponse('Video.jsp?id={0}'.format(self._params['id']))
        if response.isSucceeded:
          video = response.body['videos']
          vd = self._getVideoInfo(video)
          nw.playStream(self._handle, vd['title'], vd['img'], video['file_video'], 'video', { 'title' : vd['title'], 'plot' : vd['descr'] })
      elif 'page' in self._params:
        video_num = 0
        page_num = int(self._params['page'])
        page_tot = int(self._params['page_tot'])
        addon_page = int(self._params['addon_page'])
        while video_num < 30 and page_num <= page_tot:
          response = self._getVirginResponse('VideoList.jsp?x_pag=1&page={0}'.format(page_num), show_error_msg = False)
          if response.isSucceeded:
            page_tot = response.body['total']
            if response.body['videos'] != None and len(response.body['videos']) > 0:
              for video in response.body['videos']:
                li = self._setVideoListItem(video)
                video_num += 1
          page_num += 1

        if page_num < page_tot:
          nw.createNextPageItem(self._handle, addon_page, { 'action' : 'v', 'page' : page_num + 1, 'page_tot' : page_tot, 'addon_page' : addon_page + 1 }, self._fanart)

        xbmcplugin.endOfDirectory(self._handle)

    # Video - download.
    elif self._params['action'] == 'd':
      response = self._getVirginResponse('Video.jsp?id={0}'.format(self._params['id']))
      if response.isSucceeded:
        video = response.body['videos']
        vd = self._getVideoInfo(video)
        name = ''.join([i if ord(i) < 128 else '' for i in vd['title'].replace(' ', '_')])
        name = '{0}.mp4'.format(name)
        os.chdir(nw.addon.getSetting('download_path'))
        #~ subprocess.call([nw.addon.getSetting('ffmpeg_path'), '-i', video['file_video'], '-c', 'copy', name])
        subprocess.Popen([nw.addon.getSetting('ffmpeg_path'), '-i', video['file_video'], '-c', 'copy', name])
      else:
        nw.showVideoNotAvailable()

    # Radio
    elif self._params['action'] == 'r':
      response = self._getVirginResponse('WebRadioList.jsp')
      if response.isSucceeded:
        self._setRadiosListItem(response.body['webradios']['webradioChannel'])
        self._setRadiosListItem(response.body['webradios']['musicStar'])

      xbmcplugin.endOfDirectory(self._handle)

      if response == None or not response or not response.isSucceeded:
        nw.showNotification(nw.getTranslation(30004))

    # Podcast.
    elif self._params['action'] == 'p':
      if 'id' in self._params:
        response = self._getVirginResponse('PodcastAudio.jsp?slug={0}'.format(self._params['id']))
        if response.isSucceeded:
          for podcast in response.body['podcast_audio']['podcasts']:
            title = self._formatTitle(podcast)
            li = nw.createListItem(title, fanart = self._params['fanart'], streamtype = 'music', infolabels = { 'title' : title }, isPlayable = True)
            xbmcplugin.addDirectoryItem(self._handle, podcast['file'], li)
      else:
        response = self._getVirginResponse('PodcastAudioList.jsp?imageSize=1280x720')
        if response.isSucceeded:
          for podcast in response.body['podcast_audio']:
            title = podcast['titolo']
            img = podcast['immagine']
            descr = self._formatDescr(podcast)
            li = nw.createListItem(title, thumbnailImage = img, fanart = self._fanart, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr })
            xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'p', 'id' : podcast['slug'], 'fanart' : img }), li, True)

      xbmcplugin.endOfDirectory(self._handle)

    # Foto.
    elif self._params['action'] == 'f':
      response = self._getVirginResponse('Gallery.jsp?id={0}'.format(self._params['id']))
      if response.isSucceeded:
        for idx, photo in enumerate(response.body['gallery']['immagini']):
          title = '{0} {1}'.format(nw.getTranslation(30005), idx + 1)
          img = photo['thumb'].replace('100/100', self._def_size_img)
          li = nw.createListItem(title, thumbnailImage = img, fanart = self._params['fanart'], streamtype = 'image', infolabels = { 'title' : title })
          xbmcplugin.addDirectoryItem(self._handle, photo['original'], li)

      xbmcplugin.endOfDirectory(self._handle)