Пример #1
0
 def _getEpisodes(self, path):
     index = path.rfind('/')
     videos = self._getMTVResponse('{0}.rss'.format(path[:index]))
     if videos.isSucceeded:
         videos = videos.body.findAll('item')
         season = '{0}/'.format(path[index:])
         for video in videos:
             if video.link.nextSibling.find(season) > -1:
                 name = video.title.text
                 img = video.enclosure['url']
                 iResEnd = img.rfind('.')
                 iResStart = iResEnd - 3
                 if img[iResStart:iResEnd] == '140':
                     img = '{0}640{1}'.format(img[:iResStart],
                                              img[iResEnd:])
                 li = Util.createListItem(name,
                                          thumbnailImage=img,
                                          streamtype='video',
                                          infolabels={
                                              'title': name,
                                              'plot': video.description.text
                                          },
                                          isPlayable=True)
                 xbmcplugin.addDirectoryItem(
                     self._handle,
                     Util.formatUrl({
                         'action': 'r',
                         'path': video.link.nextSibling
                     }), li)
         xbmcplugin.endOfDirectory(self._handle)
Пример #2
0
 def _getEpisodes(self, showId, seasonId):
     url = 'http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}'.format(
         showId, seasonId)
     episodes = Util.getResponseJson(url)
     if episodes.isSucceeded:
         for episode in episodes.body['data']:
             if episode['title'].lower().find('episodio') > -1:
                 title = episode['title']
             else:
                 title = Util.getTranslation(30011).format(
                     episode=episode['title'], number=episode['episode'])
             img = episode['image_data']
             desc = episode['description'] or episode[
                 'video_metadata_longDescription']
             time = self._getDuration(int(episode['video_metadata_length']))
             li = Util.createListItem(title,
                                      thumbnailImage=self._getImage(img),
                                      streamtype='video',
                                      infolabels={
                                          'title': title,
                                          'plot': desc
                                      },
                                      duration=time,
                                      isPlayable=True)
             xbmcplugin.addDirectoryItem(
                 self._handle,
                 Util.formatUrl({
                     'action': 'v',
                     'url': episode['hls']
                 }), li)
         xbmcplugin.endOfDirectory(self._handle)
Пример #3
0
 def _getShowsPage(self, Page, Items):
     shows = Util.getResponseJson(
         "http://it.dplay.com/api/v2/ajax/modules?items={0}&page_id=32&module_id=26&page={1}".format(Items, Page)
     )
     if shows.isSucceeded:
         for show in shows.body["data"]:
             episodes = 0
             for ti in show["taxonomy_items"]:
                 if ti["type"] == "show":
                     episodes = ti["metadata"]["episodes"]
                     break  # Stops "for ti in show['taxonomy_items']:".
             title = Util.getTranslation(30009).format(show=show["title"], number=episodes)
             img = show["image_data"]
             li = Util.createListItem(
                 title,
                 thumbnailImage=self._getImage(img),
                 streamtype="video",
                 infolabels={"title": title, "plot": show["description"]},
             )
             xbmcplugin.addDirectoryItem(
                 self._handle, Util.formatUrl({"action": "s", "showid": show["id"]}), li, True
             )
         pages = shows.body["total_pages"]
         if Page < pages - 1:
             self._getShowsPage(Page + 1, Items)
         else:
             xbmcplugin.endOfDirectory(self._handle)
Пример #4
0
 def _getShowsPage(self, Page, Items):
     shows = Util.getResponseJson(
         'http://it.dplay.com/api/v2/ajax/modules?items={0}&page_id=32&module_id=26&page={1}'
         .format(Items, Page))
     if shows.isSucceeded:
         for show in shows.body['data']:
             episodes = 0
             for ti in show['taxonomy_items']:
                 if ti['type'] == 'show':
                     episodes = ti['metadata']['episodes']
                     break  # Stops "for ti in show['taxonomy_items']:".
             title = Util.getTranslation(30009).format(show=show['title'],
                                                       number=episodes)
             img = show['image_data']
             li = Util.createListItem(title,
                                      thumbnailImage=self._getImage(img),
                                      streamtype='video',
                                      infolabels={
                                          'title': title,
                                          'plot': show['description']
                                      })
             xbmcplugin.addDirectoryItem(
                 self._handle,
                 Util.formatUrl({
                     'action': 's',
                     'showid': show['id']
                 }), li, True)
         pages = shows.body['total_pages']
         if Page < pages - 1:
             self._getShowsPage(Page + 1, Items)
         else:
             xbmcplugin.endOfDirectory(self._handle)
Пример #5
0
 def _showNextPage(self, html, urlId):
   nextPage = html.find('span', 'current')
   if nextPage != None:
     nextPage = nextPage.nextSibling
     if nextPage != None and len(str(nextPage)) < 2:
       nextPage = nextPage.nextSibling
     if nextPage != None:
       Util.createNextPageItem(self._handle, nextPage.text, { 'id' : urlId, 'page' : nextPage['href'] })
Пример #6
0
 def _playVideo(self, response, title, img, descr):
   urlParam = response.find('div', 'meride-video-container')
   if urlParam != None:
     response = Util.getResponseBS('http://mediasp.meride.tv/embedproxy.php/{0}/folder1/{1}/desktop'.format(urlParam['data-customer'], urlParam['data-embed']))
     if response.isSucceeded:
       try:
         Util.playStream(self._handle, title, img, response.body.iphone.text, 'video', { 'title' : title, 'plot' : descr })
       except:
         Util.playStream(self._handle, title, img, response.body.mp4.text, 'video', { 'title' : title, 'plot' : descr })
 def _nextPage(self, bsSource, paramId, urlStringFormat):
   nextPage = bsSource.find('ul', 'swiper-wrapper jgrid')
   if nextPage != None:
     pages = nextPage.findAll('li')
     index = -1
     for page in pages:
       if page.a['class'] == 'active cc':
         index = pages.index(page) + 1
         break # Stops "for page in pages:".
     if index < len(pages):
       Util.createNextPageItem(self._handle, pages[index].a.text, { 'id' : paramId, 'page' : urlStringFormat.format(pages[index].a['href']) })
Пример #8
0
 def _showList(self, html, urlId):
   videos = html.findAll('div', { 'class' : re.compile('post-[0-9]+ (?:post|puntate).+?') })
   for video in videos:
     if video.find('div', 'icon-post flaticon-facetime') != None:
       title = video.a['title']
       descr = video.find('div', 'post-content')
       descr.a.extract()
       img = 'DefaultVideo.png'
       if video.img != None:
         img = self._normalizeImage(video.img['src'])
       li = Util.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr.text }, isPlayable = True)
       xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'v', 'page' : video.a['href'] }), li, False)
   self._showNextPage(html, urlId)
   xbmcplugin.endOfDirectory(self._handle)
Пример #9
0
 def _getEpisodes(self, showId, seasonId):
   url = 'http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}'.format(showId, seasonId)
   episodes = Util.getResponseJson(url)
   if episodes.isSucceeded:
     for episode in episodes.body['data']:
       if episode['title'].lower().find('episodio') > -1:
         title = episode['title']
       else:
         title = Util.getTranslation(30011).format(episode = episode['title'], number = episode['episode'])
       img = episode['image_data']
       desc = episode['description'] or episode['video_metadata_longDescription']
       time = self._getDuration(int(episode['video_metadata_length']))
       li = Util.createListItem(title, thumbnailImage = self._getImage(img), streamtype = 'video', infolabels = { 'title' : title, 'plot' : desc }, duration = time, isPlayable = True)
       xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 'v', 'url' : episode['hls'] }), li)
     xbmcplugin.endOfDirectory(self._handle)
Пример #10
0
 def _getEpisodes(self, path):
   index = path.rfind('/')
   videos = self._getMTVResponse('{0}.rss'.format(path[:index]))
   if videos.isSucceeded:
     videos = videos.body.findAll('item')
     season = '{0}/'.format(path[index:])
     for video in videos:
       if video.link.nextSibling.find(season) > -1:
         name = video.title.text
         img = video.enclosure['url']
         iResEnd = img.rfind('.')
         iResStart = iResEnd - 3
         if img[iResStart:iResEnd] == '140':
           img = '{0}640{1}'.format(img[:iResStart], img[iResEnd:])
         li = Util.createListItem(name, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : name, 'plot' : video.description.text }, isPlayable = True)
         xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 'r', 'path' : video.link.nextSibling }), li)
     xbmcplugin.endOfDirectory(self._handle)
Пример #11
0
 def _getEpisodes(self, showId, seasonId):
     url = "http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}".format(
         showId, seasonId
     )
     episodes = Util.getResponseJson(url)
     if episodes.isSucceeded:
         for episode in episodes.body["data"]:
             if episode["title"].lower().find("episodio") > -1:
                 title = episode["title"]
             else:
                 title = Util.getTranslation(30011).format(episode=episode["title"], number=episode["episode"])
             img = episode["image_data"]
             desc = episode["description"] or episode["video_metadata_longDescription"]
             time = self._getDuration(int(episode["video_metadata_length"]))
             li = Util.createListItem(
                 title,
                 thumbnailImage=self._getImage(img),
                 streamtype="video",
                 infolabels={"title": title, "plot": desc},
                 duration=time,
                 isPlayable=True,
             )
             xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({"action": "v", "url": episode["hls"]}), li)
         xbmcplugin.endOfDirectory(self._handle)
Пример #12
0
 def _getMTVResponse(self, link):
   return Util.getResponseBS('http://ondemand.mtv.it{0}'.format(link))
Пример #13
0
  def __init__(self):

    # Programmi.
    if len(self._params) == 0:
      shows = self._getMTVResponse('/serie-tv')
      if shows.isSucceeded:
        shows = shows.body.findAll('h3', 'showpass')
        for show in shows:
          name = show.nextSibling.strong.text
          img = show.img['data-original']
          index = img.rfind('?')
          show.nextSibling.strong.extract()
          li = Util.createListItem(name, thumbnailImage = img[:index], streamtype = 'video', infolabels = { 'title' : name, 'plot' : show.nextSibling.text })
          xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 's', 'path' : show.a['href'] }), li, True)
        xbmcplugin.endOfDirectory(self._handle)

    # Stagioni.
    elif self._params['action'] == 's':
      response = self._getMTVResponse(self._params['path'])
      if response.isSucceeded:
        if response.body.renderContents().find('<h2>Troppo tardi! <b>&#9787;</b></h2>') == -1:
          seasons = response.body.find('ul', 'nav').findAll('a')
          if xbmcplugin.getSetting(self._handle, 'show_seasons') == 'false' or len(seasons) > 1:
            title = response.body.find('h1', { 'itemprop' : 'name' }).text
            for season in seasons:
              link = season['href']
              season = season.text
              li = Util.createListItem(season, streamtype = 'video', infolabels = { 'title' : season, 'plot' : '{0} di {1}'.format(season, title) })
              xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 'p', 'path' : link }), li, True)
            xbmcplugin.endOfDirectory(self._handle)
          else:
            self._getEpisodes(seasons[0]['href'])
        else:
          xbmcgui.Dialog().ok(Util._addonName, Util.getTranslation(30000)) # Troppo tardi! I diritti di questo video sono scaduti.

    # Puntate.
    elif self._params['action'] == 'p':
      self._getEpisodes(self._params['path'])

    # Risoluzioni.
    elif self._params['action'] == 'r':
      videoId = Util.getResponseBS(self._params['path'])
      if videoId.isSucceeded:
        videoId = videoId.body.find('div', 'MTVNPlayer')
        if videoId != None:
          qlySetting = xbmcplugin.getSetting(self._handle, 'vid_quality')
          if qlySetting == '0':
            qlySetting = 180
          elif qlySetting == '1':
            qlySetting = 270
          elif qlySetting == '2':
            qlySetting = 360
          elif qlySetting == '3':
            qlySetting = 432
          elif qlySetting == '4':
            qlySetting = 576
          elif qlySetting == '5':
            qlySetting = 720
          elif qlySetting == '6':
            qlySetting = 1080
          videoId = videoId['data-contenturi']
          response = Util.getResponseBS('http://intl.esperanto.mtvi.com/www/xml/media/mediaGen.jhtml?uri=mgid:uma:video:mtv.it{0}'.format(videoId[videoId.rfind(':'):]))
          if response.isSucceeded:
            response = response.body.findAll('rendition')
            streams = []
            for stream in response:
              streams.append(( abs(qlySetting - int(stream['height'])), stream.src.text ))
            streams = sorted(streams, key = lambda stream: stream[0])
            Util.playStream(self._handle, '', path = streams[0][1])
            #for duration, bitrate, url in streams:
            #  title = Util.getTranslation(idLabel)
            #  idLabel += 1
            #  li = Util.createListItem(title, streamtype = 'video', infolabels = { 'title' : title }, duration = duration)
            #  xbmcplugin.addDirectoryItem(self._handle, '{0} swfUrl=http://media.mtvnservices.com/player/prime/mediaplayerprime.2.3.7.swf?uri={1}.swf swfVfy=true'.format(url, self._params['path']), li, False)
            #xbmcplugin.endOfDirectory(self._handle)
        else:
          xbmcgui.Dialog().ok(Util._addonName, Util.showVideoNotAvailableDialog()) # Video non disponibile.
  def __init__(self):

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

      Util.createAudioVideoItems(self._handle)

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

    elif len(self._params) == 1 and self._params['content_type'] == 'video': # Visualizzazione del menu video.

      # Menu.
      response = Util.getResponseBS('http://tv.ilfattoquotidiano.it')

      if response.isSucceeded:

        menuItems = []
        for ul in response.body.findAll('ul', 'nav-list'):
          for li in ul.findAll('li'):
            title = li.a.text
            link = li.a['href']
            li = Util.createListItem(title)
            menuItems.append(( li, link, title ))

        div = response.body.find('div', 'submenu-categories')
        for li in div.findAll('li'):
          link = li.a['href']
          found = False
          for item in menuItems:
            if item[1] == link:
              found = True
              break
          if not found:
            title = li.a.text
            li = Util.createListItem(title)
            menuItems.append(( li, link, title ))

        for item in sorted(menuItems, key = lambda item: item[2]):
          xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'c', 'page' : item[1] }), item[0], True)

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

    elif len(self._params) == 1 and self._params['content_type'] == 'audio': # Visualizzazione del menu audio.

      img = '{0}/resources/images/fqRadio.png'.format(os.path.dirname(os.path.abspath(__file__)))
      li = Util.createListItem(Util.getTranslation(30000), thumbnailImage = img) # Radio.
      xbmcplugin.addDirectoryItem(self._handle, 'http://fqradio.ns0.it:8000/;audio.mp3', li, False)
      xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'p', 'page' : self._getUrlPodcast() }), Util.createListItem(Util.getTranslation(30001), thumbnailImage = 'DefaultAddonLyrics.png'), True)

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

    else:

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

        # Videos.
        if self._params['id'] == 'c': # Visualizzazione video di una categoria.
          videos = response.body.findAll('section', 'article-preview')
          for video in videos:
            divTitle = video.find('div', 'article-wrapper')
            title = divTitle.h3.a.text
            img = None
            if video.picture.img != None:
              img = video.picture.img['src']
            li = Util.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title }, isPlayable = True)
            xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'v', 'page' : divTitle.h3.a['href'] }), li, False)

          # Next page.
          self._nextPage(response.body, 'c', '{0}')

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

        # Podcast.
        if self._params['id'] == 'p': # Visualizzazione podcast.
          podcasts = response.body.find('section', 'fqRadio fqRadio-palinsesto')
          podcasts = podcasts.findAll('div', 'ungrid-row')
          for podcast in podcasts:
            title = u'{0} ({1})'.format(podcast.find('div', 'ungrid-col program').a.text, podcast.find('div', 'ungrid-col program-date').text)
            url = podcast.find('div', 'ungrid-col dwl-podcast').a['href']
            li = Util.createListItem(title, thumbnailImage = 'DefaultAudio.png', streamtype = 'audio', infolabels = { 'title' : title })
            xbmcplugin.addDirectoryItem(self._handle, url, li, False)

          # Next page.
          self._nextPage(response.body, 'p', '{0}/{1}'.format(self._getUrlPodcast(), '{0}'))

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

        # 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('div', 'tv-desc-body').text

          # Video del fatto.
          video = response.body.find('video', { 'id' : 'bcPlayer' })
          if video != None:
            #playerID = 2274739660001
            #publisherID = 1328010481001
            url = 'https://edge.api.brightcove.com/playback/v1/accounts/{0}/videos/{1}'.format(video['data-account'], video['data-video-id'])
            headers = { 'Accept' : 'application/json;pk=BCpkADawqM0xNxj2Rs11iwmFoNJoG2nXUQs67brI7oR2qm0Dwn__kPcbvLJb7M34IY2ar-WxWvi8wHr6cRbP7nmgilWaDrqZEeQm4O5K6z6B2A3afiPFbv7T4LcsQKN2PqIIgIIr3AXq43vL' }
            response = Util.getResponseJson(url, headers)
            if response.isSucceeded:

              sources = sorted(response.body['sources'], key = lambda item: item['avg_bitrate'] if 'avg_bitrate' in item else 0, reverse = True)
              if 'src' in sources[0]:
                source = sources[0]['src']
              else:
                source = sources[1]['src']

              Util.playStream(self._handle, title, img, source, 'video', { 'title' : title, 'plot' : descr })

          # Altri video.
          else:
            responseString = response.body.renderContents()

            # Video di youtube.
            if responseString.find('www.youtube.com/embed') > -1:
              video = re.search('http://www.youtube.com/embed/(.+?)\?', response.body.find('iframe')['src'])
              if video != None:
                Util.playStream(self._handle, title, img, 'plugin://plugin.video.youtube/play/?video_id={0}'.format(video.group(1)), 'video', { 'title' : title, 'plot' : descr })

            # Video servizio pubblico.
            elif responseString.find('meride-video-container') > -1:
              params = { 'id' : 'e', 'page' : self._params['page'], 'title' : title, 'img' : img, 'descr' : descr }
              url = Util.formatUrl(params, 'plugin://plugin.video.serviziopubblico/')
              Util.playStream(self._handle, title, img, url, 'video', { 'title' : title, 'plot' : descr })

            # Video non gestito.
            else:
              Util.showVideoNotAvailableDialog()
Пример #15
0
  def __init__(self):

    # Shows.
    if len(self._params) == 0:
      shows = Util.getResponseJson('http://it.dplay.com/api/v2/ajax/modules?items=1000&page_id=32&module_id=26')
      if shows.isSucceeded:
        for show in shows.body['data']:
          episodes = 0
          for ti in show['taxonomy_items']:
            if ti['type'] == 'show':
              episodes = ti['metadata']['episodes']
              break # Stops "for ti in show['taxonomy_items']:".
          title = Util.getTranslation(30009).format(show = show['title'], number = episodes)
          img = show['image_data']
          li = Util.createListItem(title, thumbnailImage = self._getImage(img), streamtype = 'video', infolabels = { 'title' : title, 'plot' : show['description'] })
          xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 's', 'showid' : show['id'] }), li, True)
        xbmcplugin.endOfDirectory(self._handle)

    # Seasons.
    elif self._params['action'] == 's':
      headers = { 'User-Agent' : 'Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)' }
      url = 'http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1'.format(self._params['showid'])
      seasons = Util.getResponseJson(url, headers)
      if seasons.isSucceeded:
        if xbmcplugin.getSetting(self._handle, 'show_seasons') == 'false' or len(seasons.body['data']) > 1:
          for season in seasons.body['data']:
            title = Util.getTranslation(30010).format(season = season['name'], numberof = season['episodes_available'], numbertot = season['episodes_total'])
            li = Util.createListItem(title, thumbnailImage = 'DefaultFolder.png', streamtype = 'video', infolabels = { 'title' : title })
            xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 'e', 'showid' : self._params['showid'], 'seasonid' : season['id'] }), li, True)
          xbmcplugin.endOfDirectory(self._handle)
        else:
          self._getEpisodes(self._params['showid'], seasons.body['data'][0]['id'])

    # Episodes.
    elif self._params['action'] == 'e':
      self._getEpisodes(self._params['showid'], self._params['seasonid'])

    # Play video.
    elif self._params['action'] == 'v':
      stream = Util.getResponseForRegEx(self._params['url'])
      if stream.isSucceeded:
        qlySetting = xbmcplugin.getSetting(self._handle, 'vid_quality')
        if qlySetting == '0':
          qlySetting = 180
        elif qlySetting == '1':
          qlySetting = 270
        elif qlySetting == '2':
          qlySetting = 360
        elif qlySetting == '3':
          qlySetting = 432
        elif qlySetting == '4':
          qlySetting = 576
        elif qlySetting == '5':
          qlySetting = 720
        elif qlySetting == '6':
          qlySetting = 1080
        urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#', stream.body)
        items = []
        for qly, url in urls:
          items.append(( abs(qlySetting - int(qly)), url ))
        items = sorted(items, key = lambda item: item[0])
        Util.playStream(self._handle, '', path = items[0][1])
Пример #16
0
    def __init__(self):

        # Shows.
        if len(self._params) == 0:
            self._getShowsPage(0, xbmcplugin.getSetting(self._handle, "items_per_page"))

        # Seasons.
        elif self._params["action"] == "s":
            headers = {"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)"}
            url = "http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1".format(
                self._params["showid"]
            )
            seasons = Util.getResponseJson(url, headers)
            if seasons.isSucceeded:
                if xbmcplugin.getSetting(self._handle, "show_seasons") == "false" or len(seasons.body["data"]) > 1:
                    for season in seasons.body["data"]:
                        title = Util.getTranslation(30010).format(
                            season=season["name"],
                            numberof=season["episodes_available"],
                            numbertot=season["episodes_total"],
                        )
                        li = Util.createListItem(
                            title, thumbnailImage="DefaultFolder.png", streamtype="video", infolabels={"title": title}
                        )
                        xbmcplugin.addDirectoryItem(
                            self._handle,
                            Util.formatUrl({"action": "e", "showid": self._params["showid"], "seasonid": season["id"]}),
                            li,
                            True,
                        )
                    xbmcplugin.endOfDirectory(self._handle)
                else:
                    self._getEpisodes(self._params["showid"], seasons.body["data"][0]["id"])

        # Episodes.
        elif self._params["action"] == "e":
            self._getEpisodes(self._params["showid"], self._params["seasonid"])

        # Play video.
        elif self._params["action"] == "v":
            stream = Util.getResponseForRegEx(self._params["url"])
            if stream.isSucceeded:
                qlySetting = xbmcplugin.getSetting(self._handle, "vid_quality")
                if qlySetting == "0":
                    qlySetting = 180
                elif qlySetting == "1":
                    qlySetting = 270
                elif qlySetting == "2":
                    qlySetting = 360
                elif qlySetting == "3":
                    qlySetting = 432
                elif qlySetting == "4":
                    qlySetting = 576
                elif qlySetting == "5":
                    qlySetting = 720
                elif qlySetting == "6":
                    qlySetting = 1080
                urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#', stream.body)
                items = []
                for qly, url in urls:
                    items.append((abs(qlySetting - int(qly)), url))
                items = sorted(items, key=lambda item: item[0])
                Util.playStream(self._handle, "", path=items[0][1])
Пример #17
0
    def __init__(self):

        # Shows.
        if len(self._params) == 0:
            self._getShowsPage(
                0, xbmcplugin.getSetting(self._handle, 'items_per_page'))

        # Seasons.
        elif self._params['action'] == 's':
            headers = {
                'User-Agent':
                'Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)'
            }
            url = 'http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1'.format(
                self._params['showid'])
            seasons = Util.getResponseJson(url, headers)
            if seasons.isSucceeded:
                if xbmcplugin.getSetting(self._handle,
                                         'show_seasons') == 'false' or len(
                                             seasons.body['data']) > 1:
                    for season in seasons.body['data']:
                        title = Util.getTranslation(30010).format(
                            season=season['name'],
                            numberof=season['episodes_available'],
                            numbertot=season['episodes_total'])
                        li = Util.createListItem(
                            title,
                            thumbnailImage='DefaultFolder.png',
                            streamtype='video',
                            infolabels={'title': title})
                        xbmcplugin.addDirectoryItem(
                            self._handle,
                            Util.formatUrl({
                                'action': 'e',
                                'showid': self._params['showid'],
                                'seasonid': season['id']
                            }), li, True)
                    xbmcplugin.endOfDirectory(self._handle)
                else:
                    self._getEpisodes(self._params['showid'],
                                      seasons.body['data'][0]['id'])

        # Episodes.
        elif self._params['action'] == 'e':
            self._getEpisodes(self._params['showid'], self._params['seasonid'])

        # Play video.
        elif self._params['action'] == 'v':
            stream = Util.getResponseForRegEx(self._params['url'])
            if stream.isSucceeded:
                qlySetting = xbmcplugin.getSetting(self._handle, 'vid_quality')
                if qlySetting == '0':
                    qlySetting = 180
                elif qlySetting == '1':
                    qlySetting = 270
                elif qlySetting == '2':
                    qlySetting = 360
                elif qlySetting == '3':
                    qlySetting = 432
                elif qlySetting == '4':
                    qlySetting = 576
                elif qlySetting == '5':
                    qlySetting = 720
                elif qlySetting == '6':
                    qlySetting = 1080
                urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#',
                                  stream.body)
                items = []
                for qly, url in urls:
                    items.append((abs(qlySetting - int(qly)), url))
                items = sorted(items, key=lambda item: item[0])
                Util.playStream(self._handle, '', path=items[0][1])
Пример #18
0
  def __init__(self):

    # Visualizzazione del menu.
    if len(self._params) == 0:
      categs = []
      categs.append(['Santoro', 'r', '/canali/santoro'])
      categs.append(['Vauro', 'r', '/canali/vauro'])
      categs.append(['Travaglio', 'r', '/canali/travaglio'])
      categs.append(['Dragoni', 'r', '/canali/dragoni'])
      categs.append(['Puntate', 'i', '/puntate'])
      categs.append(['Argomenti', 't', '/argomenti'])
      categs.append(['Gli inviati', 'n', '/gli-inviati'])
      for title, paramId, page in categs:
        li = Util.createListItem(title, streamtype = 'video', infolabels = { 'title' : title })
        xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : paramId, 'page' : page }), li, True)
      xbmcplugin.endOfDirectory(self._handle)
    else:
      response = Util.getResponseBS(self._createPage(self._params['page']))
      if response.isSucceeded:

        # Archivi (santoro, vauro, travaglio, dragoni, puntate, argomenti e inviati).
        if self._params['id'] == 'i':
          self._showArchiveList(response.body, self._params['id'])

        # Argomenti.
        elif self._params['id'] == 't':
          categs = response.body.findAll('div', 'col-xs-12 single-argomento')
          for categ in categs:
            title = categ.a['title']
            img = 'DefaultVideo.png'
            if categ.img != None:
              img = self._normalizeImage(categ.img['src'])
            li = Util.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title, 'plot' : categ.div.renderContents() })
            xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'r', 'page' : categ.a['href'] }), li, True)
          self._showNextPage(response.body, self._params['id'])
          xbmcplugin.endOfDirectory(self._handle)

        # Gli inviati.
        elif self._params['id'] == 'n':
          envoys = response.body.findAll('div', { 'class' : re.compile('post-[0-9]+ persone.+?') })
          for envoy in envoys:
            title = envoy.a['title']
            li = Util.createListItem(title, thumbnailImage = self._normalizeImage(envoy.img['src']), streamtype = 'video', infolabels = { 'title' : title })
            xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'i', 'page' : envoy.a['href'] }), li, True)
          xbmcplugin.endOfDirectory(self._handle)

        # Ricerca categID.
        elif self._params['id'] == 'r':
          categid = re.search('\?cat_id=([0-9]+)"', response.body.renderContents())
          if categid != None:
            categid = categid.group(1)
            link = self._GetSPPage('/?p=15546&cat_id={0}'.format(categid))
            if categid == '2': # Per evitare di mangiarsi un video adotto questo barbatrucco.
              link = self._GetSPPage('/?p=15526&cat_id=2')
            response = Util.getResponseBS(link)
            if response.isSucceeded:
              self._showArchiveList(response.body, 'i')

        # Riproduzione del video.
        elif self._params['id'] == 'v':
          img = response.body.find('meta', { 'property' : 'og:image' })['content']
          tide = response.body.find('h3', 'entry-title')

          responseString = response.body.renderContents()

          # Servizio pubblico.
          if responseString.find('meride-video-container') > -1:
            self._playVideo(response.body, tide.text, img, tide.parent.text)

          # Fatto quotidiano.
          elif responseString.find('<object id="flashObj"') > -1:
            urlParam = response.body.find('param', { 'name' : 'flashVars' })['value']
            urlParam = re.search("linkBaseURL=(.+?)&", urlParam).group(1).replace('%3A', ':').replace('%2F', '/')
            url = Util.formatUrl({ 'id' : 'v', 'page' : urlParam }, 'plugin://plugin.video.fattoquotidianotv/')
            Util.playStream(self._handle, tide.text, img, url, 'video', { 'title' : tide.text, 'plot' : tide.parent.text })

          else:
            Util.showVideoNotAvailableDialog()

        # Riproduzione video esterna.
        elif self._params['id'] == 'e':
          self._playVideo(response.body, self._params['title'], self._params['img'], self._params['descr'])
Пример #19
0
#!/usr/bin/python
import os
from neverwise import Util

li = Util.createListItem(
    Util._addonName,
    thumbnailImage="{0}/icon.png".format(os.path.dirname(os.path.abspath(__file__))),
    streamtype="music",
    infolabels={"title": Util._addonName},
)
xbmc.Player(xbmc.PLAYER_CORE_PAPLAYER).play("http://dancewave.hopto.org/dance.mp3", li)
Пример #20
0
 def _getMTVResponse(self, link):
     return Util.getResponseBS('http://ondemand.mtv.it{0}'.format(link))
Пример #21
0
class Dplay(object):

    _handle = int(sys.argv[1])
    _params = Util.urlParametersToDict(sys.argv[2])

    def __init__(self):

        # Shows.
        if len(self._params) == 0:
            self._getShowsPage(
                0, xbmcplugin.getSetting(self._handle, 'items_per_page'))

        # Seasons.
        elif self._params['action'] == 's':
            headers = {
                'User-Agent':
                'Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)'
            }
            url = 'http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1'.format(
                self._params['showid'])
            seasons = Util.getResponseJson(url, headers)
            if seasons.isSucceeded:
                if xbmcplugin.getSetting(self._handle,
                                         'show_seasons') == 'false' or len(
                                             seasons.body['data']) > 1:
                    for season in seasons.body['data']:
                        title = Util.getTranslation(30010).format(
                            season=season['name'],
                            numberof=season['episodes_available'],
                            numbertot=season['episodes_total'])
                        li = Util.createListItem(
                            title,
                            thumbnailImage='DefaultFolder.png',
                            streamtype='video',
                            infolabels={'title': title})
                        xbmcplugin.addDirectoryItem(
                            self._handle,
                            Util.formatUrl({
                                'action': 'e',
                                'showid': self._params['showid'],
                                'seasonid': season['id']
                            }), li, True)
                    xbmcplugin.endOfDirectory(self._handle)
                else:
                    self._getEpisodes(self._params['showid'],
                                      seasons.body['data'][0]['id'])

        # Episodes.
        elif self._params['action'] == 'e':
            self._getEpisodes(self._params['showid'], self._params['seasonid'])

        # Play video.
        elif self._params['action'] == 'v':
            stream = Util.getResponseForRegEx(self._params['url'])
            if stream.isSucceeded:
                qlySetting = xbmcplugin.getSetting(self._handle, 'vid_quality')
                if qlySetting == '0':
                    qlySetting = 180
                elif qlySetting == '1':
                    qlySetting = 270
                elif qlySetting == '2':
                    qlySetting = 360
                elif qlySetting == '3':
                    qlySetting = 432
                elif qlySetting == '4':
                    qlySetting = 576
                elif qlySetting == '5':
                    qlySetting = 720
                elif qlySetting == '6':
                    qlySetting = 1080
                urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#',
                                  stream.body)
                items = []
                for qly, url in urls:
                    items.append((abs(qlySetting - int(qly)), url))
                items = sorted(items, key=lambda item: item[0])
                Util.playStream(self._handle, '', path=items[0][1])

    def _getShowsPage(self, Page, Items):
        shows = Util.getResponseJson(
            'http://it.dplay.com/api/v2/ajax/modules?items={0}&page_id=32&module_id=26&page={1}'
            .format(Items, Page))
        if shows.isSucceeded:
            for show in shows.body['data']:
                episodes = 0
                for ti in show['taxonomy_items']:
                    if ti['type'] == 'show':
                        episodes = ti['metadata']['episodes']
                        break  # Stops "for ti in show['taxonomy_items']:".
                title = Util.getTranslation(30009).format(show=show['title'],
                                                          number=episodes)
                img = show['image_data']
                li = Util.createListItem(title,
                                         thumbnailImage=self._getImage(img),
                                         streamtype='video',
                                         infolabels={
                                             'title': title,
                                             'plot': show['description']
                                         })
                xbmcplugin.addDirectoryItem(
                    self._handle,
                    Util.formatUrl({
                        'action': 's',
                        'showid': show['id']
                    }), li, True)
            pages = shows.body['total_pages']
            if Page < pages - 1:
                self._getShowsPage(Page + 1, Items)
            else:
                xbmcplugin.endOfDirectory(self._handle)

    def _getEpisodes(self, showId, seasonId):
        url = 'http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}'.format(
            showId, seasonId)
        episodes = Util.getResponseJson(url)
        if episodes.isSucceeded:
            for episode in episodes.body['data']:
                if episode['title'].lower().find('episodio') > -1:
                    title = episode['title']
                else:
                    title = Util.getTranslation(30011).format(
                        episode=episode['title'], number=episode['episode'])
                img = episode['image_data']
                desc = episode['description'] or episode[
                    'video_metadata_longDescription']
                time = self._getDuration(int(episode['video_metadata_length']))
                li = Util.createListItem(title,
                                         thumbnailImage=self._getImage(img),
                                         streamtype='video',
                                         infolabels={
                                             'title': title,
                                             'plot': desc
                                         },
                                         duration=time,
                                         isPlayable=True)
                xbmcplugin.addDirectoryItem(
                    self._handle,
                    Util.formatUrl({
                        'action': 'v',
                        'url': episode['hls']
                    }), li)
            xbmcplugin.endOfDirectory(self._handle)

    def _getImage(self, image):
        if image is not None:
            return u'{0}c_fill,h_246,w_368/{1}'.format(
                'http://res.cloudinary.com/db79cecgq/image/upload/',
                image['file'])
        else:
            return 'DefaultVideo.png'

    def _getDuration(self, milliseconds):
        return str(timedelta(milliseconds / 1000.0))
Пример #22
0
class MTV(object):

    _handle = int(sys.argv[1])
    _params = Util.urlParametersToDict(sys.argv[2])

    def __init__(self):

        # Programmi.
        if len(self._params) == 0:
            shows = self._getMTVResponse('/serie-tv')
            if shows.isSucceeded:
                shows = shows.body.findAll('h3', 'showpass')
                for show in shows:
                    name = show.nextSibling.strong.text
                    img = show.img['data-original']
                    index = img.rfind('?')
                    show.nextSibling.strong.extract()
                    li = Util.createListItem(name,
                                             thumbnailImage=img[:index],
                                             streamtype='video',
                                             infolabels={
                                                 'title': name,
                                                 'plot': show.nextSibling.text
                                             })
                    xbmcplugin.addDirectoryItem(
                        self._handle,
                        Util.formatUrl({
                            'action': 's',
                            'path': show.a['href']
                        }), li, True)
                xbmcplugin.endOfDirectory(self._handle)

        # Stagioni.
        elif self._params['action'] == 's':
            response = self._getMTVResponse(self._params['path'])
            if response.isSucceeded:
                if response.body.renderContents().find(
                        '<h2>Troppo tardi! <b>&#9787;</b></h2>') == -1:
                    seasons = response.body.find('ul', 'nav').findAll('a')
                    if xbmcplugin.getSetting(
                            self._handle,
                            'show_seasons') == 'false' or len(seasons) > 1:
                        title = response.body.find('h1', {
                            'itemprop': 'name'
                        }).text
                        for season in seasons:
                            link = season['href']
                            season = season.text
                            li = Util.createListItem(season,
                                                     streamtype='video',
                                                     infolabels={
                                                         'title':
                                                         season,
                                                         'plot':
                                                         '{0} di {1}'.format(
                                                             season, title)
                                                     })
                            xbmcplugin.addDirectoryItem(
                                self._handle,
                                Util.formatUrl({
                                    'action': 'p',
                                    'path': link
                                }), li, True)
                        xbmcplugin.endOfDirectory(self._handle)
                    else:
                        self._getEpisodes(seasons[0]['href'])
                else:
                    xbmcgui.Dialog().ok(
                        Util._addonName, Util.getTranslation(30000)
                    )  # Troppo tardi! I diritti di questo video sono scaduti.

        # Puntate.
        elif self._params['action'] == 'p':
            self._getEpisodes(self._params['path'])

        # Risoluzioni.
        elif self._params['action'] == 'r':
            videoId = Util.getResponseBS(self._params['path'])
            if videoId.isSucceeded:
                videoId = videoId.body.find('div', 'MTVNPlayer')
                if videoId != None:
                    qlySetting = xbmcplugin.getSetting(self._handle,
                                                       'vid_quality')
                    if qlySetting == '0':
                        qlySetting = 180
                    elif qlySetting == '1':
                        qlySetting = 270
                    elif qlySetting == '2':
                        qlySetting = 360
                    elif qlySetting == '3':
                        qlySetting = 432
                    elif qlySetting == '4':
                        qlySetting = 576
                    elif qlySetting == '5':
                        qlySetting = 720
                    elif qlySetting == '6':
                        qlySetting = 1080
                    videoId = videoId['data-contenturi']
                    response = Util.getResponseBS(
                        'http://intl.esperanto.mtvi.com/www/xml/media/mediaGen.jhtml?uri=mgid:uma:video:mtv.it{0}'
                        .format(videoId[videoId.rfind(':'):]))
                    if response.isSucceeded:
                        response = response.body.findAll('rendition')
                        streams = []
                        for stream in response:
                            streams.append(
                                (abs(qlySetting - int(stream['height'])),
                                 stream.src.text))
                        streams = sorted(streams, key=lambda stream: stream[0])
                        Util.playStream(self._handle, '', path=streams[0][1])
                        #for duration, bitrate, url in streams:
                        #  title = Util.getTranslation(idLabel)
                        #  idLabel += 1
                        #  li = Util.createListItem(title, streamtype = 'video', infolabels = { 'title' : title }, duration = duration)
                        #  xbmcplugin.addDirectoryItem(self._handle, '{0} swfUrl=http://media.mtvnservices.com/player/prime/mediaplayerprime.2.3.7.swf?uri={1}.swf swfVfy=true'.format(url, self._params['path']), li, False)
                        #xbmcplugin.endOfDirectory(self._handle)
                else:
                    xbmcgui.Dialog().ok(Util._addonName,
                                        Util.showVideoNotAvailableDialog()
                                        )  # Video non disponibile.

    def _getMTVResponse(self, link):
        return Util.getResponseBS('http://ondemand.mtv.it{0}'.format(link))

    def _getEpisodes(self, path):
        index = path.rfind('/')
        videos = self._getMTVResponse('{0}.rss'.format(path[:index]))
        if videos.isSucceeded:
            videos = videos.body.findAll('item')
            season = '{0}/'.format(path[index:])
            for video in videos:
                if video.link.nextSibling.find(season) > -1:
                    name = video.title.text
                    img = video.enclosure['url']
                    iResEnd = img.rfind('.')
                    iResStart = iResEnd - 3
                    if img[iResStart:iResEnd] == '140':
                        img = '{0}640{1}'.format(img[:iResStart],
                                                 img[iResEnd:])
                    li = Util.createListItem(name,
                                             thumbnailImage=img,
                                             streamtype='video',
                                             infolabels={
                                                 'title': name,
                                                 'plot': video.description.text
                                             },
                                             isPlayable=True)
                    xbmcplugin.addDirectoryItem(
                        self._handle,
                        Util.formatUrl({
                            'action': 'r',
                            'path': video.link.nextSibling
                        }), li)
            xbmcplugin.endOfDirectory(self._handle)
Пример #23
0
#!/usr/bin/python
import os
from neverwise import Util

li = Util.createListItem(Util._addonName,
                         thumbnailImage='{0}/icon.png'.format(
                             os.path.dirname(os.path.abspath(__file__))),
                         streamtype='music',
                         infolabels={'title': Util._addonName})
xbmc.Player(xbmc.PLAYER_CORE_PAPLAYER).play(
    'http://dancewave.hopto.org/dance.mp3', li)
Пример #24
0
#!/usr/bin/python
import os
from neverwise import Util

# http://resetdiretta.ns0.it:8000 # URL alternativo.
# Ho tentato di inserire il nome della radio tra le informazioni della canzone ma dallo stream ricevo le informazioni della canzone corrente che cancellano il nome della radio.
li = Util.createListItem(Util._addonName, thumbnailImage = '{0}/icon.png'.format(os.path.dirname(os.path.abspath(__file__))), streamtype = 'music', infolabels = { 'title' : Util._addonName })
xbmc.Player(xbmc.PLAYER_CORE_PAPLAYER).play('http://resetradiolive.ns0.it:8000', li)