def resolve(self):
     """resolves one of the available alternate versions of a playable item
     @return: the resolved playable url for XBMC
     @raise UnresolvableSourceException: if none of the alternate links can be resolved"""
     for url in self.__urls:
         try:
             notifier = notification.getUserNotifier('Looking for playable link...', 'trying link %s of %s' % (self.__urls.index(url), len(self.__urls)))
             try:
                 return self.__resolveAlternate(url)
             except:
                 log.exception("Failed to resolve alternate link")
         finally:
             notifier.close()
     raise UnresolvableSourceException("No links found on %s" % (self.__sourceName))
Example #2
0
 def resolve(self):
     """resolves one of the available alternate versions of a playable item
     @return: the resolved playable url for XBMC
     @raise UnresolvableSourceException: if none of the alternate links can be resolved"""
     for url in self.__urls:
         try:
             notifier = notification.getUserNotifier(
                 'Looking for playable link...', 'trying link %s of %s' %
                 (self.__urls.index(url), len(self.__urls)))
             try:
                 return self.__resolveAlternate(url)
             except:
                 log.exception("Failed to resolve alternate link")
         finally:
             notifier.close()
     raise UnresolvableSourceException("No links found on %s" %
                                       self.__sourceName)
def _preChacheThumbnail(url, reason="May  take  a  while..."):
    '''Cache  an  image  file  (cover  or  backdrop)
    @param  url:  the  url  of  the  image  file  to  cache  locally
    @param  reason:  the  reason  to  inform  the  user  with,  since  this  is  may  take  a  while
    @return:  the  path  to  the  file  cached  locally'''
    if url is None or url == "":  return ""
    try:
        filename = xbmc.getCacheThumbName(url)
        filepath = CACHE_PATH_FORMAT % (filename[0], filename)
        log.debug("Got thumbnail path '%s' for file '%s'" % (filename, url))
        if not os.path.isfile(filepath):
            notifier = notification.getUserNotifier("Downloading  artwork", reason)
            log.debug("Caching  thumbnail  '%s'  for  remote  file  '%s'" % (filename, url))
            urllib.urlretrieve(url, filepath)
            urllib.urlcleanup()
            notifier.close()
        log.debug("Returning  thumb  '%s'  for  file  '%s'" % (filename, url))
        return filepath
    except:
        log.exception("Failed  to  cache  thumbnail:  %s" % url)
        return url
def _preChacheThumbnail(url, reason="May  take  a  while..."):
    '''Cache  an  image  file  (cover  or  backdrop)
    @param  url:  the  url  of  the  image  file  to  cache  locally
    @param  reason:  the  reason  to  inform  the  user  with,  since  this  is  may  take  a  while
    @return:  the  path  to  the  file  cached  locally'''
    if url is None or url == "": return ""
    try:
        filename = xbmc.getCacheThumbName(url)
        filepath = CACHE_PATH_FORMAT % (filename[0], filename)
        log.debug("Got thumbnail path '%s' for file '%s'" % (filename, url))
        if not os.path.isfile(filepath):
            notifier = notification.getUserNotifier("Downloading  artwork",
                                                    reason)
            log.debug("Caching  thumbnail  '%s'  for  remote  file  '%s'" %
                      (filename, url))
            urllib.urlretrieve(url, filepath)
            urllib.urlcleanup()
            notifier.close()
        log.debug("Returning  thumb  '%s'  for  file  '%s'" % (filename, url))
        return filepath
    except:
        log.exception("Failed  to  cache  thumbnail:  %s" % url)
        return url
    def resolve(self, url):
        if url.find('putlocker') < 0:
            raise Exception("not a putlocker link")

        notifier = notification.getUserNotifier('PutLocker', 'Initializing resolver...')

        http = self.getHttpClient()

        try:

            # login to use pro account
            if not self.isLoggedIn():
                from utils import pluginsupport, settings

                username = settings.get("putlocker-user")
                password = settings.get("putlocker-pass")

                if username and password and not self.isLoggedIn():
                    loginData = pluginsupport.encodeArgs({'user': username, 'pass': password, 'login_submit': 'Login'})
                    notifier.update(20, "performing login for premium link...")
                    log.debug("loggin in '%s' to pulocker.com" % str(username))
                    http.get('http://www.putlocker.com/authenticate.php?login', data=loginData)
                    notifier.update(30, "logged in...")
                    self.__loggedIn = True
                    log.debug("logged in? '%s'" % str(self.isLoggedIn()))
                else:
                    # find session hash
                    notifier.update(0, "getting page to parse session hash...")
                    page = http.get(url)
                    hash = re.search('value="([0-9a-f]+?)" name="hash"', page).group(1)
                    notifier.update(10, "got hash '%s'... waiting 5 seconds to POST..." % hash)
                    log.info('now waiting 5 seconds to post confirmation data...')
                    for i in range(0, 5):
                        sleep(1)
                        log.info(i + 1)

                    postData = pluginsupport.encodeArgs({'hash': hash, 'confirm': 'Continue as Free User'})
                    notifier.update(40, "done waiting... now POSTing hash '%s'..." % hash)
                    log.debug("posting hash and confirmation for free user: '******'" % str(postData))
                    page = http.get(url, data=postData)

            notifier.update(50, "getting rss feed url from page")
            page = http.get(url)
            rssFeedUrl = 'http://www.putlocker.com' + re.search("playlist: '(/get_file.php.+?)'", page).group(1)
            # get the rss feed xml to load the video stream location from
            notifier.update(70, "requesting rss feed xml from '%s'" % rssFeedUrl)
            log.debug("now loading rss feed xml. url is '%s'" % str(rssFeedUrl))
            page = http.get(rssFeedUrl)

            mediaUrlMatch = re.search('url="(.+?)"', page)
            if mediaUrlMatch:
                resolvedUrl = mediaUrlMatch.group(1)
                if url.find('expired_link'):
                    raise Exception("link is expired")
                notifier.update(90, "resolved url to play: '%s'" % resolvedUrl)
                log.debug("found stream link: '%s'" % resolvedUrl)
                return resolvedUrl

        finally:
            notifier.close()

        log.debug("url not found for putlocker...")