Пример #1
0
 def autoSelectQuality(playable):
     player_type = _player_type_.lower()
     if player_type == "hls":
         player_type = "iPad"
     setting_quality = ivysilani.Quality(_quality_, player_type)
     setting_quality.ad = _audio_description_
     url = playable.url(setting_quality)
     if url or not _quality_fallback_:
         return url
     all_qualities = ["720p", "576p", "404p", "288p", "144p"]
     for q in all_qualities:
         quality = ivysilani.Quality(q, player_type)
         if setting_quality.height < quality.height:
             continue
         url = playable.url(quality)
         if url and quality.ad == setting_quality.ad:
             return url
         else:
             if _player_fallback_:
                 all_players = ["iPad", "rtsp"]
                 for p in all_players:
                     quality = ivysilani.Quality(q, p)
                     url = playable.url(quality)
                     if url and quality.ad == setting_quality.ad:
                         return url
     return None
Пример #2
0
 def autoSelectQuality(playable):
     setting_quality = ivysilani.Quality(_quality_)
     url = playable.url(setting_quality)
     if url or not _quality_fallback_:
         return url
     all_qualities = ["1080p", "720p", "576p", "404p", "288p", "144p"]
     for q in all_qualities:
         quality = ivysilani.Quality(q)
         if setting_quality.height < quality.height:
             continue
         url = playable.url(quality)
         if url:
             return url
     return None
Пример #3
0
 def autoSelectQuality(playable):
     setting_quality = ivysilani.Quality(_quality_)
     url, subtitlesURL = playable.url(setting_quality)
     if url or not _quality_fallback_:
         return (url, subtitlesURL)
     all_qualities = ["720p", "576p", "404p", "288p", "144p"]
     for q in all_qualities:
         quality = ivysilani.Quality(q)
         if setting_quality.height < quality.height:
             continue
         url, subtitlesURL = playable.url(quality)
         if url:
             return (url, subtitlesURL)
     return (None, None)
Пример #4
0
    def resolve(self, item, captcha_cb=None, select_cb=None):
        result = []
        item = item.copy()
        play = get_params(item['url'])['play']
        playable = self.selectLiveChannel(play)
        if not playable:
            playable = ivysilani.Programme(play)
            image = ""  #os.path.join(_addon_.getAddonInfo('path'), 'resources', 'media', 'logo_' + playable.ID.lower() + '_400x225.png')
        if isinstance(playable, ivysilani.Programme):
            image = playable.imageURL
        manifest = util.request(playable.url(ivysilani.Quality("web")))
        #for m in re.finditer('#EXT-X-STREAM-INF:PROGRAM-ID=\d+,BANDWIDTH=(?P<bandwidth>\d+)\s(?P<chunklist>[^\s]+)', manifest, re.DOTALL):
        for m in re.finditer(
                '#EXT-X-STREAM-INF:PROGRAM-ID=\d+,BANDWIDTH=(?P<bandwidth>\d+),AUDIO="\d+"\s(?P<chunklist>[^\s]+)',
                manifest, re.DOTALL):
            item = self.video_item()
            item['title'] = _toString(playable.title)
            bandwidth = int(m.group('bandwidth'))
            if bandwidth < 500000:
                item['quality'] = "144p"
            if bandwidth >= 500000 and bandwidth < 1032000:
                item['quality'] = "288p"
            elif bandwidth >= 1032000 and bandwidth < 2048000:
                item['quality'] = "404p"
            elif bandwidth >= 2048000 and bandwidth < 3584000:
                item['quality'] = "576p"
            else:
                item['quality'] = "720p"
            item['url'] = m.group('chunklist')
            result.append(item)
        result = sorted(result, key=lambda i: i['quality'], reverse=True)
        if len(result) > 0 and select_cb:
            return select_cb(result)

        return result
Пример #5
0
 def playPlayable(playable, skipAutoQuality=False, forceQuality=None):
     image = xbmc.translatePath(
         os.path.join(_addon_.getAddonInfo('path'), 'resources', 'media',
                      'logo_' + playable.ID.lower() + '_400x225.png'))
     if isinstance(playable, ivysilani.Programme):
         image = playable.imageURL
     if _auto_quality_ and not skipAutoQuality and not forceQuality:
         url, subtitlesURL = autoSelectQuality(playable)
         if url:
             playUrl(playable.title, url, image, subtitlesURL)
             return
     if forceQuality:
         quality = ivysilani.Quality(forceQuality)
         url, subtitlesURL = playable.url(quality)
         if url:
             playUrl(playable.title, url, image, subtitlesURL)
             return
     qualities = playable.available_qualities()
     for quality in qualities:
         addDirectoryItem(quality.label(),
                          url=_baseurl_ + "?force_quality=" + str(quality) +
                          "&play=" + playable.ID,
                          title=_toString(playable.title),
                          image=image,
                          isFolder=False)
     xbmcplugin.endOfDirectory(_handle_,
                               updateListing=False,
                               cacheToDisc=False)
Пример #6
0
 def downloadPlayable(playable, skipAutoQuality=False, forceQuality=None):
     #===========================================================================================
     # analogical playPlayable() see line 321, needs to be implemented together with
     # downloadUrl(title,url,image,subtitlesURL) and downloadAndMerge(my_url,title) see above
     # needs to cope with skip_auto=1 means user should choose quality for download
     # for current implementation see line: 195 where it is direct passed skip_auto=0
     #===========================================================================================
     xbmc.log('"downloadPlayable reached"')
     image = xbmc.translatePath(
         os.path.join(_addon_.getAddonInfo('path'), 'resources', 'media',
                      'logo_' + playable.ID.lower() + '_400x225.png'))
     if isinstance(playable, ivysilani.Programme):
         image = playable.imageURL
     if _auto_quality_ and not skipAutoQuality and not forceQuality:
         url, subtitlesURL = autoSelectQuality(playable)
         if url:
             downloadUrl(playable.title, url, image, subtitlesURL)
             return
     if forceQuality:
         quality = ivysilani.Quality(forceQuality)
         url, subtitlesURL = playable.url(quality)
         if url:
             downloadUrl(playable.title, url, image, subtitlesURL)
             return
     qualities = playable.available_qualities()
     xbmc.log('"Quality needs to be choose by user"')
     for quality in qualities:
         addDirectoryItem(quality.label(),
                          url=_baseurl_ + "?force_quality=" + str(quality) +
                          "&play=" + playable.ID + "&download=1",
                          title=_toString(playable.title),
                          image=image,
                          isFolder=False)
     xbmcplugin.endOfDirectory(_handle_,
                               updateListing=False,
                               cacheToDisc=False)