Пример #1
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 })
Пример #2
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])
Пример #3
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()
Пример #5
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])
Пример #6
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'])
Пример #7
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])
Пример #8
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.