def listCategory(url, name, letter=None):
    log.debug("calling list categories %r" % name)
    if settings.isSet("group-categories-by-letter") and not letter:
        log.debug("listing all letter filters for category %r" % name)
        return _listLetters(url, name)
    # delegate to listCategoryLetter with no filter, to list all
    log.debug("listing with no letter filter for category %r" % name)
    return _listCategory(url, name, letter)
Example #2
0
def listCategory(url, name, letter=None):
    log.debug("calling list categories %r" % name)
    if settings.isSet("group-categories-by-letter") and not letter:
        log.debug("listing all letter filters for category %r" % name)
        return _listLetters(url, name)
        # delegate to listCategoryLetter with no filter, to list all
    log.debug("listing with no letter filter for category %r" % name)
    return _listCategory(url, name, letter)
Example #3
0
def resolveFiles(url, name, forceSourceSelection=False):
    """Resolve the files for a movie/episode/... item

    Resolving a file is split into three phases:
    1-Select file source (megavideo, veoh, tudou, youku, ...)
    2-Load parts (if item is split for the selected source)
    3-Resolve file links for the parts from the previous step

    If an item has only one available source, then that source is auto-selected, otherwise
    the user is shown a XBMC dialog to select the source. If the 'autoplay-preferred-source'
    setting is enabled, the first available source that matches the 'preferred-source' setting
    will be auto-selected.

    @param url: the url to resolve files for
    @param label: the label of the playable item being resolved
    @param forceSourceSelection: if the user should be forced to select the source (default False)
    @return: a list of urls of the files to play"""
    log.debug("Listing sources: %s, forceSelection: %s" % (url, forceSourceSelection))
    html = http.get(__url(url), cleanup=True)

    alternateLinks = [(itemUrl, getSourceName(itemSource)) for (itemUrl, itemSource) in
                      re.compile(SOURCE_PATTERN, re.DOTALL).findall(html)]

    # The url on the page is to another primewire page, the actual external url is in a parameter of the url
    outsideLinks = []
    for link, name in alternateLinks:
        match = re.compile(".+?&url=(.+?)&.+?").findall(link)[0]
        outsideLinks.append((match.decode('base-64'), name))

    log.debug("found links in page: %s" % str(outsideLinks))
    from utils.sources import SourceList

    sources = SourceList([(url, name) for url, name in outsideLinks],
                         settings.isSet("filter-unsupported-sources"))

    autoSelectSource = None
    if settings.isSet("autoplay-preferred-source"):
        autoSelectSource = settings.get("preferred-source").split(',')

    selected = sources.selectSource(forceSourceSelection, autoSelectSource)
    if selected:
        link = selected.resolve()
        log.debug("resolved link for video: %s" % str(link))
        return PluginResult(1, [LWTPluginMovieItem(name, link)])
def resolveFiles(url, name, forceSourceSelection=False):
    '''Resolve the files for a movie/episode/... item
    
    Resolving a file is split into three phases:
    1-Select file source (megavideo, veoh, tudou, youku, ...)
    2-Load parts (if item is split for the selected source)
    3-Resolve file links for the parts from the previous step
    
    If an item has only one available source, then that source is auto-selected, otherwise
    the user is shown a XBMC dialog to select the source. If the 'autoplay-preferred-source'
    setting is enabled, the first available source that matches the 'preferred-source' setting
    will be auto-selected.
    
    @param url: the url to resolve files for
    @param label: the label of the playable item being resolved
    @param forceSourceSelection: if the user should be forced to select the source (default False)
    @return: a list of urls of the files to play'''
    log.debug("Listing sources: %s, forceSelection: %s" % (url, forceSourceSelection))
    html = http.get(__url(url), cleanup=True)

    alternateLinks = [(itemUrl, getSourceName(itemSource)) for (itemUrl, itemSource) in re.compile(SOURCE_PATTERN, re.DOTALL).findall(html)]
    log.debug("found links in page: %s" % str(alternateLinks))
    from linkresolvers import SourceList
    sources = SourceList([(__url(url), name) for url, name in alternateLinks],
                         settings.isSet("filter-unsupported-sources"))

    autoSelectSource = None
    if settings.isSet("autoplay-preferred-source"):
        autoSelectSource = settings.get("preferred-source")

    selected = sources.selectSource(forceSourceSelection, autoSelectSource)
    if selected:
        metadata = __parseTvShowMetadata(html)
        link = selected.resolve()
        log.debug("resolved link for video: %s" % str(link))
        return PluginResult(1, [LWTPluginMovieItem(name, link, metadata=metadata)])
 def loadEpisode(self, metadata):
     season_num = metadata.getSeason()
     episode_num = metadata.getEpisode()
     tvshow_id = metadata.getTvShowId()
     log.debug("Loading details for tv show episode id: %s" % str(tvshow_id))
     episode = tvdb.get_episode(tvshow_id, season_num, episode_num)
     log.debug("Loading details: %s" % str(episode))
     episodeId = episode['id']
     episodename = episode["name"]
     firstAired = episode['first_aired']
     if firstAired:
         firstAired = firstAired.date()
     metadata.title(episodename).season(episode['season_number']).episode(episode['episode_number'])
     metadata.plot(episode["overview"]).premiered(str(firstAired)).code(episodeId)
     if settings.isSet("load-episode-cover") and episode["image"]:
         cover = "http://thetvdb.com/banners/%s" % episode["image"]
         metadata.cover(cover)
     log.debug("Created episode metadata from TVDB: %s" % metadata)
     return metadata
 def hasFanart(self):
     return self.hasMetadata() and self.metadata.hasFanart() and settings.isSet("load-tv-fanart")
def get(url, plot="", cover="", queryOnlineDb=False, bypassCache=False, title=None, tvshow=None, persistUpdates=True):
    '''Get the metadata for an url.
    If possible, get the cached metadata, otherwise, query IMDB/THETVDB for it
    If this fails, return default metadata built with what is available from tv shack
    
    Will try to return from cache and if not possible will refresh cache with freshly built metadata
    
    A metadata key is in the format: <type>/<title> e.g: tv/How_I_met_your_mother
    
    @param url: the url to load metadata for
    @param plot: fallback plot to build default metadata with (default "")
    @param cover: fallback cover to build default metadata with (default "")
    @param queryOnlineDb: if we should search for items not in cache (default False)
    @param bypassCache: if we should bypass cache (to force searching) (default False)
    @param title: fallback title to build default metadata with (default None)
    @param tvshow: title of the tvshow (default None)
    @return: metadata for the url'''
    entry = MetadataKey(url, title)
    if entry.isTVShow() and tvshow:
        entry.setUseTVShowCache()

    log.debug("Created key for url: %s, %s" % (url, str(entry)))
    cache = MetadataCache(entry)
    log.debug("Cache loaded: %s" % id(cache))
    log.debug("Querying cache for entry: %s" % entry)
    cached = cache.lookup(entry)
    # only override cache if query is not disabled
    bypassCache = bypassCache and not settings.isSet("metadata-query-skip")
    if not bypassCache and cached is not None:
        if not cache.contains(entry, False):
            log.debug("Updating show cache from episodes cache...%s" % str(entry.getKey()))
            cache.refresh(entry.getKey(), cached, persist=True)
        #log.debug("Returning from cache...%s" % str(cached))      
        return cached

    log.debug("Not returning from cache... building new...")
    # build default metadata
    metadata = Metadata(entry.getName(), plot, cover)
    # coz episodes need more info to load metadata
    if entry.isEpisode():
        seasonNumber, episodeNumber = entry.getSeasonAndEpisode()
        metadata.season(seasonNumber).episode(episodeNumber)
        if tvshow:
            metadata.tvshow(tvshow.getTitle()).tvshowid(tvshow.getId()).cover(tvshow.getCover())
        elif cached:
            tvshowid = cached.getTvShowId()
            tvshowcover = cached.getCover()
            if not tvshowid or not tvshowcover:
                # look for the parent entry and try to load it from there
                tvshowentry = entry.getParentKey()
                tvshowmeta = cache.lookup(tvshowentry)
                tvshowid = tvshowmeta.getId() or tvshowid
                tvshowcover = tvshowmeta.getCover()
            log.info("Decorating with cached data, tvshowid = %s" % str(tvshowid))
            metadata.tvshowid(tvshowid).cover(tvshowcover)

    if queryOnlineDb and not settings.isSet("metadata-query-skip"):
        try:
            if entry.isMovie() or entry.isTVShow():
                dbid = metadataLoader.search(entry)
                if dbid:
                    log.info("Loading metadata for '%s'" % dbid)
                    metadataLoader.load(entry, metadata.code(dbid))
            elif entry.isEpisode():
                metadataLoader.load(entry, metadata)
        except:
            log.exception("Querying metadata failed")

    # update the cache
    if not metadata.isEmpty():
        cache.refresh(entry.getKey(), metadata, persistUpdates)
    return metadata
def __getUrl(mega):
  megavideocookie = __doLogin()
  if settings.isSet("megavideopremium"):
    return __getPremiumUrl(mega, megavideocookie)
  else:
    return __getPublicUrl(mega, megavideocookie)