예제 #1
0
  def download(self,pod_session,  id):
    podserver = xmlrpclib.Server('http://ssp.podnapisi.net:8000')
    user_agent = "%s_v%s" % (__scriptname__.replace(" ","_"),__version__ )
    init = podserver.initiate(user_agent)
    
    id_pod =[]
    id_pod.append(str(id))    
    username = __settings__.getSetting( "PNuser" )
    password = __settings__.getSetting( "PNpass" )

    hash = md5()
    hash.update(password)
    password = hash.hexdigest()
    password256 = sha256.sha256(str(password) + str(init['nonce'])).hexdigest()
    if str(init['status']) == "200":
      pod_session = init['session']
      auth = podserver.authenticate(pod_session, username, password256)
      if auth['status'] == 300: 
        log( __name__ ,"Authenticate [%s]" % "InvalidCredentials")
      download = podserver.download(pod_session , id_pod)
      if str(download['status']) == "200" and len(download['names']) > 0 :
        download_item = download["names"][0]
        if str(download["names"][0]['id']) == str(id):
          return "http://www.podnapisi.net/static/podnapisi/%s" % download["names"][0]['filename']
          
    return None  
예제 #2
0
    def download(self, pod_session, id):
        podserver = xmlrpclib.Server('http://ssp.podnapisi.net:8000')
        user_agent = "%s_v%s" % (__scriptname__.replace(" ", "_"), __version__)
        init = podserver.initiate(user_agent)

        id_pod = []
        id_pod.append(str(id))
        username = __settings__.getSetting("PNuser")
        password = __settings__.getSetting("PNpass")

        hash = md5()
        hash.update(password)
        password = hash.hexdigest()
        password256 = sha256.sha256(str(password) +
                                    str(init['nonce'])).hexdigest()
        if str(init['status']) == "200":
            pod_session = init['session']
            auth = podserver.authenticate(pod_session, username, password256)
            if auth['status'] == 300:
                log(__name__, "Authenticate [%s]" % "InvalidCredentials")
            download = podserver.download(pod_session, id_pod)
            if str(download['status']) == "200" and len(download['names']) > 0:
                download_item = download["names"][0]
                if str(download["names"][0]['id']) == str(id):
                    return "http://www.podnapisi.net/static/podnapisi/%s" % download[
                        "names"][0]['filename']

        return None
    def searchsubtitles_pod( self, movie_hash, lang1,lang2,lang3):
#      movie_hash = "e1b45885346cfa0b" # Matrix Hash, Debug only
      podserver = xmlrpclib.Server('http://ssp.podnapisi.net:8000')      
      pod_session = ""
      hash_pod =[]
      hash_pod.append(movie_hash)      
      lang = []
      lang.append(lang1)
      if lang1!=lang2:
        lang.append(lang2)
      if lang3!=lang2 and lang3!=lang1:
        lang.append(lang3)

      log( __name__ ,"Languages : [%s]" % str(lang))
      log( __name__ ,"Hash : [%s]" % str(hash_pod))
      try:
        user_agent = "%s_v%s" % (__scriptname__.replace(" ","_"),__version__ )
        init = podserver.initiate(user_agent)

        username = __settings__.getSetting( "PNuser" )
        password = __settings__.getSetting( "PNpass" )

        hash = md5()
        hash.update(password)
        password = hash.hexdigest()
        password256 = sha256.sha256(str(password) + str(init['nonce'])).hexdigest()
        if str(init['status']) == "200":
          pod_session = init['session']

          auth = podserver.authenticate(pod_session, username, password256)
          filt = podserver.setFilters(pod_session, True, lang , False)
      
          log( __name__ ,"Auth : [%s]" % str(auth) )                                              
          log( __name__ ,"Filter : [%s]" % str(filt) )
          search = podserver.search(pod_session , hash_pod)
          if str(search['status']) == "200" and len(search['results']) > 0 :
            item2 = search["results"][movie_hash]
            for item in item2["subtitles"]:
              if item["lang"]:
                flag_image = "flags/%s.gif" % (item["lang"],)
              else:                                                           
                flag_image = "-.gif"
              link =  "http://www.podnapisi.net/ppodnapisi/download/i/%s" % str(item["id"])
              
              if item['release'] == "":
                episode = item2["tvEpisode"]
                if str(episode) == "0":
                  name = "%s (%s)" % (str(item2["movieTitle"]),str(item2["movieYear"]),)
                else:
                  name = "%s S(%s)E(%s)" % (str(item2["movieTitle"]),str(item2["tvSeason"]), str(episode), )
              else:
                name = item['release']
                
              if item["inexact"]:
                sync1 = False
              else:
                sync1 = True
              self.subtitles_hash_list.append({'filename':name,'link':link,"language_name":twotofull(item["lang"]),"language_flag":flag_image,"language_id":item["lang"],"ID":item["id"],"sync":sync1, "format":"srt", "rating": str(int(item['rating'])*2) })
          self.mergesubtitles()
        return self.subtitles_list,pod_session
      except :
        return self.subtitles_list,pod_session
예제 #4
0
    def searchsubtitles_pod(self, movie_hash, lang1, lang2, lang3, stack):
        #      movie_hash = "e1b45885346cfa0b" # Matrix Hash, Debug only
        podserver = xmlrpclib.Server('http://ssp.podnapisi.net:8000')
        pod_session = ""
        hash_pod = []
        hash_pod.append(movie_hash)
        lang = []
        lang.append(lang1)
        if lang1 != lang2:
            lang.append(lang2)
        if lang3 != lang2 and lang3 != lang1:
            lang.append(lang3)

        log(__name__, "Languages : [%s]" % str(lang))
        log(__name__, "Hash : [%s]" % str(hash_pod))
        try:
            user_agent = "%s_v%s" % (__scriptname__.replace(" ",
                                                            "_"), __version__)
            init = podserver.initiate(user_agent)

            username = __settings__.getSetting("PNuser")
            password = __settings__.getSetting("PNpass")

            hash = md5()
            hash.update(password)
            password = hash.hexdigest()
            password256 = sha256.sha256(str(password) +
                                        str(init['nonce'])).hexdigest()
            if str(init['status']) == "200":
                pod_session = init['session']

                auth = podserver.authenticate(pod_session, username,
                                              password256)
                filt = podserver.setFilters(pod_session, True, lang, False)

                log(__name__, "Auth : [%s]" % str(auth))
                log(__name__, "Filter : [%s]" % str(filt))
                search = podserver.search(pod_session, hash_pod)
                if str(search['status']) == "200" and len(
                        search['results']) > 0:
                    item2 = search["results"][movie_hash]
                    for item in item2["subtitles"]:
                        if item["lang"]:
                            flag_image = "flags/%s.gif" % (item["lang"], )
                        else:
                            flag_image = "-.gif"

                        link = str(item["id"])
                        if item['release'] == "":
                            episode = item2["tvEpisode"]
                            if str(episode) == "0":
                                name = "%s (%s)" % (
                                    str(item2["movieTitle"]),
                                    str(item2["movieYear"]),
                                )
                            else:
                                name = "%s S(%s)E(%s)" % (
                                    str(item2["movieTitle"]),
                                    str(item2["tvSeason"]),
                                    str(episode),
                                )
                        else:
                            name = item['release']

                        if item["inexact"]:
                            sync1 = False
                        else:
                            sync1 = True
                        self.subtitles_hash_list.append({
                            'filename':
                            name,
                            'link':
                            link,
                            "language_name":
                            twotofull(item["lang"]),
                            "language_flag":
                            flag_image,
                            "language_id":
                            item["lang"],
                            "ID":
                            item["id"],
                            "sync":
                            sync1,
                            "format":
                            "srt",
                            "rating":
                            str(int(item['rating']) * 2)
                        })
                self.mergesubtitles(stack)
            return self.subtitles_list, pod_session
        except:
            return self.subtitles_list, pod_session
예제 #5
0
 def searchsubtitles_pod( self, file, movie_hash, lang1,lang2,lang3):
     
             self.subtitles_hash_list = []
     
             podserver = xmlrpclib.Server('http://ssp.podnapisi.net:8000')
     
             
             lang = []
             lang11 = twotoone(lang1)
             lang.append(lang11)
             if lang1!=lang2:
                     lang22 = twotoone(lang2)
                     lang.append(lang22)
             if lang3!=lang2 and lang3!=lang1:
                     lang33 = twotoone(lang3)
                     lang.append(lang33)
             hash_pod =[]
             hash_pod.append(movie_hash)
             if self.debug : 
                     LOG( LOG_INFO, "Languages : [%s]", str(lang)  )
                     LOG( LOG_INFO, "Hash : [%s]", str(hash_pod)  )
             try:
     
                     init = podserver.initiate("OpenSubtitles_OSD")
                     try:
                             from hashlib import md5 as md5
                             from hashlib import sha256 as sha256
                     except ImportError:
                             from md5 import md5
                             import sha256
     
     
                     username = __settings__.getSetting( "PNuser" )
                     password = __settings__.getSetting( "PNpass" )
                     
                     hash = md5()
                     hash.update(password)
                     password = hash.hexdigest()
          
                     password256 = sha256.sha256(str(password) + str(init['nonce'])).hexdigest()
                     if str(init['status']) == "200":
                             self.pod_session = init['session']
     
                             auth = podserver.authenticate(self.pod_session, username, password256)
                             filt = podserver.setFilters(self.pod_session, True, lang , False)
                             
                             if self.debug : 
                                     LOG( LOG_INFO, "Filter : [%s]", str(filt)  )
                                     LOG( LOG_INFO, "Auth : [%s]", str(auth)  )                                              
                             
                             search = podserver.search(self.pod_session , hash_pod)
     
                             if str(search['status']) == "200" and len(search['results']) :
                                     item1 = search["results"]
                                     item2 = item1[movie_hash]
                                     item3 = item2["subtitles"]
     
                                     episode = item2["tvEpisode"]
     
                                     if str(episode) == "0":
                                             title = str(item2["movieTitle"]) + " (" + str(item2["movieYear"]) + ")" 
                                     else:
                                             title = str(item2["movieTitle"]) + " S ("+ str(item2["tvSeason"]) + ") E (" + str(episode) +")"
                                                                             
     
                                     for item in item3:
     
                                             if item["lang"]:
                                                     flag_image = "flags/" + item["lang"] + ".gif"
                                             else:                                                           
                                                     flag_image = "-.gif"
                                             link =  "http://www.podnapisi.net/ppodnapisi/download/i/" + str(item["id"])
                                             rating = int(item['rating'])*2
                                             name = item['release']
                                             if name == "" : name = title 
                                             
                                             if item["inexact"]:
                                                     sync1 = False
                                             else:
                                                     sync1 = True
                                                     
                                                     
                                             self.subtitles_hash_list.append({'filename':name,'link':link,"language_name":toOpenSubtitles_fromtwo(item["lang"]),"language_flag":flag_image,"language_id":item["lang"],"ID":item["id"],"sync":sync1, "format":"srt", "rating": str(rating) })
     
     
                                     message =  str( len ( self.subtitles_hash_list )  ) + " subtitles found"
                                     if self.debug : LOG( LOG_INFO, message )
                                     return True, message
                             else: 
                                     message = "No subtitles found Podnapisi_hash"
                                     if self.debug : LOG( LOG_INFO, message )
                                     return True, message
     
     
     
             except Exception, e:
                     error = "Error podnapisi Hash"
                     if self.debug : LOG( LOG_ERROR, error )
                     return False, error