Пример #1
0
def resolve(page):
  links = []
  bit = re.compile('<iframe src="(.+?)"').findall(page)
  page = htmlutils.get(bit[0])
  Id = re.compile("'VideoIDS','(.+?)'").findall(page)
  page = htmlutils.get("http://www.flvcd.com/parse.php?kw=http%3A%2F%2Fv.youku.com%2Fv_show%2Fid_" + Id[0] + "%3D%3D.html")
  match = re.compile('<a href="(.+?)" target="_blank" onclick=".+?">').findall(page)
  for url in match:
    links.append(url)
Пример #2
0
def __harvest(imdbId, html=None):
  def find(regex, html, mode=0, convert=""):
    found = re.compile(regex, mode).findall(html)
    if len(found) >= 1:
      if convert == "int":
        try: return int(found[0])
        except: return 0      
      if convert == "float":
        try: return float(found[0])
        except: return 0.0      
      return found[0]
    return "Not Found"
  
  if html == None:
    html = http.get('http://imdb.com/title/' + imdbId)
    
  genre = find(r'<h5>Genre:</h5>.+?<a href=".+?">(.+?)</a>', html, re.DOTALL)
  year = find(r'<a href="/Sections/Years/.+?/">(.+?)</a>', html, convert="int")
  image = find(r'<img border="0" alt=".+?" title=".+?" src="(.+?)" /></a>', html)
  rating = find(r'<div class="starbar-meta">.+?<b>(.+?)/10</b>', html, re.DOTALL, convert="float")
  director = find(r'<h5>Director:</h5>.+?<a href=".+?">(.+?)</a>', html, re.DOTALL)
  writer = find(r'<h5>.Writer.+?:.+?</h5>.+?<div class="info-content">.+?<a href=".+?".+?>(.+?)</a>.+?</div>', html, re.DOTALL)
  runtime = find(r'<h5>Runtime:</h5>.+?<div class="info-content">\n(.+? min).+?</div>', html, re.DOTALL)
  votes = find(r'<a href="ratings" class="tn15more">(.+?) votes</a>', html, re.DOTALL)
  #actorandrole = re.compile(r'<a href="/name/nm.+?>([A-Za-z ]+?)</a>.+?</td>.+?<td class="char">.+?<a href="/character/ch.+?>([A-Za-z ]+?)</a>', re.DOTALL).findall(html)
  actorandrole = re.compile(r'<a href="/name/nm.+?>([A-Za-z ]+?)</a>', re.DOTALL).findall(html)
  cast = []
  for actor in actorandrole:
    cast.append(actor)
  
  html = http.get('http://www.imdb.com/title/' + imdbId + '/plotsummary')
  plot = find('<p class="plotpar">\n(.+?)\n<i>\n', html)
  log.debug("found so far(1): %s, %s, %s, %s, %s, %s, %s, %s, %s" % (genre, year, image, rating, plot, director, writer, runtime, str(cast)))
  try:
    if plot.find('div') == 1:
      plot = 'No Plot found on Imdb'
  except: 
    log.warning("Could not load plot for (IMDB:%s)" % imdbId)

  if len(plot) < 1:
    plotter = http.get('http://www.imdb.com/title/' + imdbId + '/synopsis')
    clean = re.sub('\n', '', plotter)
    plot = find('<div id="swiki.2.1">(.+?)</div>', clean)
    try:
      if plot.find('div') > 0:
        plot = 'No Plot found on Imdb'
    except:
      log.warning("Could not load plot for (IMDB:%s)" % imdbId)
          
  log.debug("returning: %s, %s, %s, %s, %s, %s, %s, %s, %s" % (genre, year, image, rating, plot, director, writer, runtime, str(cast)))
  log.info("finished searching")
  return genre, year, image, rating, plot, director, writer, runtime, cast, votes, imdbId
def _listCategory(url, name, letter=None):
    '''List all the TVShows/Movies/... available
    @param url: url of the title being refreshed
    @param label: the label of the title being refreshed (used for querying)
    @param letter: letter to filter on '#' for non-letter
    @return: a list of PluginMovieItemss'''
    def _shouldInclude(name):
        if not letter or letter == ALPHA_FILTER and not name[0].isalpha():
            return True
        return letter == name[0]

    log.debug("requesting url %r for category %r" % (url, name))
    page = http.get(url, cleanup=True)
    #log.debug(page)
    match = re.compile(CATEGORY_ITEM_PATTERN).findall(page)
    #log.debug("Results: %s"%str(match))
    if letter:
        match = [item for item in match if _shouldInclude(item[1])]
    size = len(match)
    def itemGenerator():
        for itemUrl, name, year, thumb in match:
            mode = _getMode(url)
            log.debug("creating item: title: '%s' URL: '%s' mode:'%s'" % (str(name), str(itemUrl), str(mode)))
            metadata = metadatautils.get(url, title=name, cover=thumb).year(int(year))
            log.debug("creating item: '%s'" % str(metadata))
            yield LWTPluginMovieItem(name, itemUrl, mode, metadata)
        nextpageurl = __getNextPageUrl(url)
        log.debug("next page: '%s'" % str(nextpageurl))
        yield LWTPluginMovieItem("more...", nextpageurl, MODE_LIST_CATEGORY)

    log.debug("found result of size %r" % name)
    return PluginResult(size, itemGenerator)
Пример #4
0
def resolve(page):
  tweety = re.compile("(http://tweetypie.tvshack.cc/zs/\?id=.+?)'").findall(page)
  log.debug("Got tweetypie page: %s" % str(tweety[0]))
  # get the redirect url from headers
  downloadLink = http.get(tweety[0], returnResponse=True).url
  log.debug("Got zshare player page: %s" % str(downloadLink))
  downloadLink = "http://127.0.0.1:64653/zshare/%s" % base64.urlsafe_b64encode(downloadLink)
  log.debug("Resolved to proxied url: %s" % str(downloadLink))
  return [downloadLink]
def processSourcePage(page, processor):
  """Will call the processor with the first src="(.+?)" page found"""
  log.debug("frame page: %s" % str(page))
  url = re.compile('src="(http://.+?)"').findall(page)
  log.debug("Found stream page urls: %s" % str(url))
  url = url[0].replace('&amp;', '&')
  html = http.get(url)
  log.debug("Loaded stream page: %s" % str(html))
  return processor(html)
Пример #6
0
def resolve(page):
  tweety = re.compile('flashvars="file=(.+?)&type=flv').findall(page)
  # follow redirects to get the final url
  url = http.get(tweety[0], returnResponse=True).url
  log.debug("Resolved tweetypie: %s" % str(url))
  # run veoh streams through proxy
  if url.find('veoh') > 0:
    import base64
    url = "http://127.0.0.1:64653/veoh/%s" % base64.urlsafe_b64encode(url)
    log.debug("Returning proxied veoh stream: %s" % str(url))
  return [url]
Пример #7
0
def query(name):
  log.info("searching for '%s'" % name)  
  response = http.get('http://www.imdb.com/find?s=all&q=' + urllib.quote(name))
  log.debug("search(%s): %s" % (name, response))
  imdbIDs = re.compile('<b>Media from&nbsp;<a href="/title/(.+?)/"').findall(response)
  if len(imdbIDs) > 0:
    return __harvest(imdbIDs[0])
  else :
    imdbIDs = re.compile(r'<link rel="canonical" href="http://www.imdb.com/title/(.+)/"').findall(response)
    if len(imdbIDs) < 1:
      imdbIDs = re.compile(r'<a name="poster" href="/.+?/.+?/.+?-photo/media/.+?/(.+?)" title=".+?">').findall(response)
    if len(imdbIDs) > 0:
      return __harvest(imdbIDs[0], response)
    log.warning("No match found for title '%s'" % name)
Пример #8
0
def search(search_section=SEARCH_SECTION_MOVIES):
    """Do an interactive search of tvshack.cc's files
    @return: list of files matching search criteria"""
    keyb = xbmc.Keyboard('', 'Search primewire.ag')
    keyb.doModal()
    if keyb.isConfirmed():
        html = http.get("")
        searchKey = re.search('input type="hidden" name="key" value="([0-9a-f]*)"', html).group(1)
        search = keyb.getText()
        encode = urllib.quote(search).replace(' ', '+')
        html = http.get(SEARCH_URL_TPL % (encode, str(search_section), searchKey), cleanup=True)
        match = re.compile(CATEGORY_ITEM_PATTERN).findall(html)

        def itemGen():
            for itemUrl, name, year, thumb in match:
                log.debug("found item: title: '%s' URL: '%s'" % (str(name), str(itemUrl)))
                resultsmode = MODE_PLAY_ITEM
                if search_section == SEARCH_SECTION_TV:
                    resultsmode = MODE_LIST_EPISODES
                yield LWTPluginMovieItem(name, itemUrl, resultsmode)

        return PluginResult(len(match), itemGen)
    return PluginResult(0, [])
Пример #9
0
def listEpisodes(url, name):
    """List the episodes for a TV Show
    @param url: the tvshack url to load episodes from
    @param label: the tvshow being listed
    @return: a list of LWTPluginMovieItem with the episode items"""
    url = __url(url)
    html = http.get(url, cleanup=True)

    episodeLinks = re.compile(EPISODE_ITEM_PATTERN, re.DOTALL).findall(html)
    itemCount = len(episodeLinks)

    def itemGen():
        for episodeurl, episodetitle in episodeLinks:
            season, episode = re.compile("season-(.+?)-episode-(.+?)").findall(episodeurl)[0]
            yield LWTPluginMovieItem(episodetitle, episodeurl, MODE_PLAY_ITEM, season=season, episode=episode)

    return PluginResult(itemCount, itemGen)
Пример #10
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 search(search_section=SEARCH_SECTION_MOVIES):
    '''Do an interactive search of tvshack.cc's files
    @return: list of files matching search criteria'''
    keyb = xbmc.Keyboard('', 'Search 1channel.ch')
    keyb.doModal()
    if (keyb.isConfirmed()):
        search = keyb.getText()
        encode = urllib.quote(search).replace(' ', '+')
        html = http.get(SEARCH_URL_TPL % (encode, str(search_section)), cleanup=True)
        match = re.compile(CATEGORY_ITEM_PATTERN).findall(html)
        def itemGen():
            for itemUrl, name, year, thumb in match:
                log.debug("found item: title: '%s' URL: '%s'" % (str(name), str(itemUrl)))
                metadata = metadatautils.Metadata(name, cover=thumb).year(int(year))
                resultsmode = MODE_PLAY_ITEM
                if search_section == SEARCH_SECTION_TV:
                    resultsmode = MODE_LIST_EPISODES
                yield LWTPluginMovieItem(name, itemUrl, resultsmode, metadata)
        return PluginResult(len(match), itemGen)
    return PluginResult(0, [])
def listEpisodes(url, name):
    '''List the episodes for a TV Show
    @param url: the tvshack url to load episodes from
    @param label: the tvshow being listed
    @return: a list of LWTPluginMovieItem with the episode items'''
    url = __url(url)
    html = http.get(url, cleanup=True)

    tvshowmeta = __parseTvShowMetadata(html)

    episodeLinks = re.compile(EPISODE_ITEM_PATTERN, re.DOTALL).findall(html)
    itemCount = len(episodeLinks)
    def itemGen():
        episodeurl = None
        for episodeurl, episodetitle in episodeLinks:
            episodeMetadata = tvshowmeta.title(episodetitle)
            log.debug("creating item: '%s'" % str(episodeMetadata))
            yield LWTPluginMovieItem(episodetitle, episodeurl, MODE_PLAY_ITEM, episodeMetadata)

    return PluginResult(itemCount, itemGen)
Пример #13
0
def _listCategory(url, name, letter=None):
    """List all the TVShows/Movies/... available
    @param url: url of the title being refreshed
    @param label: the label of the title being refreshed (used for querying)
    @param letter: letter to filter on '#' for non-letter
    @return: a list of PluginMovieItemss"""

    def _getMode(url):
        '''Get the execution mode for this plugin
        The execution mode is used by the plugin to track the type of url being used
        @param url: the url to get the execution mode for'''
        mode = MODE_PLAY_ITEM
        if url.find('?tv') >= 0:
            mode = MODE_LIST_EPISODES
        return mode

    def _shouldInclude(name):
        if not letter or letter == ALPHA_FILTER and not name[0].isalpha():
            return True
        return letter == name[0]

    log.debug("requesting url %r for category %r" % (url, name))
    page = http.get(url, cleanup=True)
    #log.debug(page)
    match = re.compile(CATEGORY_ITEM_PATTERN).findall(page)
    #log.debug("Results: %s"%str(match))
    if letter:
        match = [item for item in match if _shouldInclude(item[1])]
    size = len(match)

    def itemGenerator():
        for itemUrl, name, year, thumb in match:
            mode = _getMode(url)
            log.debug("creating item: title: '%s' URL: '%s' mode:'%s'" % (str(name), str(itemUrl), str(mode)))
            yield LWTPluginMovieItem(name, itemUrl, mode)
        nextpageurl = __getNextPageUrl(url)
        log.debug("next page: '%s'" % str(nextpageurl))
        yield LWTPluginMovieItem("more...", nextpageurl, MODE_LIST_CATEGORY)

    log.debug("found result of size %r" % name)
    return PluginResult(size, itemGenerator)
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)])
Пример #15
0
def resolve(page):
  aiv = regexFinder('var aiv = (.+?);')(page)[0]
  internalpage = http.get("http://www.tvdex.org/includes/ajax/video_loader.php?episode_id="+aiv, True)
  return processSourcePage(internalpage, regexFinder('flashvars\.file="(.+)";'))