Exemplo n.º 1
0
    def searchsubtitlesbyimdbid( self, imdbid, language="all" ):
	self.subtitles_imdbid_list = []
        self.allow_exception = False
	
	try:
		if ( self.osdb_token ) and ( self.connected ):
			LOG( LOG_INFO, "Searching subtitles by imdbid for " + imdbid )
			
			#We try and check if the file is from an smb share
			if file.find( "//" ) == 0:
				error = _( 740 )
				LOG( LOG_ERROR, error )
				return False, error

			filename = globals.EncodeLocale( os.path.basename( file ) )
			filenameurl = ( filename ) #Corrects the accent characters.
			
			if not os.path.exists( file ):
				error = _( 738 ) % ( file, )
				LOG( LOG_ERROR, error )
				return False, error
			else:
				hash = globals.hashFile( file )
				if hash == "IOError" or hash== "SizeError":
					error = _( 739 ) % ( file, hash, )
					LOG( LOG_ERROR, error )
					return False, error		
				#We keep going if there was no error.
				videofilesize = os.path.getsize( file )
				linkhtml_index =  "search/moviebytesize-"+str( videofilesize )+"/moviehash-"+hash
				videofilename = filename
				pathvideofilename = file
				videohash = hash
				hashresult = {"hash":hash, "filename":filename, "pathvideofilename":file, "filesize":str( videofilesize )
						, "linkhtml_index":linkhtml_index}
				searchlist = []
				searchlist.append({'sublanguageid':language,'moviehash':hashresult["hash"],'moviebytesize':str( hashresult["filesize"] ) })
				search = self.server.SearchSubtitles( self.osdb_token, searchlist )
				if search["data"]:
					for item in search["data"]:
						if item["ISO639"]:
							flag_image =  item["ISO639"] + ".png"
						else:	
							flag_image = "-.png"
						self.subtitles_imdbid_list.append({'filename':item["SubFileName"],'link':item["ZipDownloadLink"],"language_name":item["LanguageName"],"language_flag":flag_image,"language_id":item["SubLanguageID"],"ID":item["IDSubtitle"],"rating":str( int( item["SubRating"][0] ) ),"format":item["SubFormat"],"sync":True})
					self.subtitles_list.append ( self.subtitles_imdbid_list )

					message =  str( len ( self.subtitles_hash_list )  ) + " subtitles found"
					LOG( LOG_INFO, message )
					return True, message
				else: 
					message = "No subtitles found"
					LOG( LOG_INFO, message )
					return True, message
	except Exception, e:
		error = _( 731 ) % ( _( 736 ), str ( e ) ) 
		LOG( LOG_ERROR, error )
		return False, error
Exemplo n.º 2
0
    def searchsubtitlesbyimdbid( self, imdbid, language="all" ):
	self.subtitles_imdbid_list = []
        self.allow_exception = False
	
	try:
		if ( self.osdb_token ) and ( self.connected ):
			LOG( LOG_INFO, "Searching subtitles by imdbid for " + imdbid )
			
			#We try and check if the file is from an smb share
			if file.find( "//" ) == 0:
				error = _( 740 )
				LOG( LOG_ERROR, error )
				return False, error

			filename = globals.EncodeLocale( os.path.basename( file ) )
			filenameurl = ( filename ) #Corrects the accent characters.
			
			if not os.path.exists( file ):
				error = _( 738 ) % ( file, )
				LOG( LOG_ERROR, error )
				return False, error
			else:
				hash = globals.hashFile( file )
				if hash == "IOError" or hash== "SizeError":
					error = _( 739 ) % ( file, hash, )
					LOG( LOG_ERROR, error )
					return False, error		
				#We keep going if there was no error.
				videofilesize = os.path.getsize( file )
				linkhtml_index =  "search/moviebytesize-"+str( videofilesize )+"/moviehash-"+hash
				videofilename = filename
				pathvideofilename = file
				videohash = hash
				hashresult = {"hash":hash, "filename":filename, "pathvideofilename":file, "filesize":str( videofilesize )
						, "linkhtml_index":linkhtml_index}
				searchlist = []
				searchlist.append({'sublanguageid':language,'moviehash':hashresult["hash"],'moviebytesize':str( hashresult["filesize"] ) })
				search = self.server.SearchSubtitles( self.osdb_token, searchlist )
				if search["data"]:
					for item in search["data"]:
						if item["ISO639"]:
							flag_image = "flags/" + item["ISO639"] + ".png"
						else:	
							flag_image = "-.png"
						self.subtitles_imdbid_list.append({'filename':item["SubFileName"],'link':item["ZipDownloadLink"],"language_name":item["LanguageName"],"language_flag":flag_image,"language_id":item["SubLanguageID"],"ID":item["IDSubtitle"],"rating":str( int( item["SubRating"][0] ) ),"format":item["SubFormat"],"sync":True})
					self.subtitles_list.append ( self.subtitles_imdbid_list )

					message = _( 742 ) % ( str( len ( self.subtitles_imdbid_list ) ), )
					LOG( LOG_INFO, message )
					return True, message
				else: 
					message = _( 741 )
					LOG( LOG_INFO, message )
					return True, message
	except Exception, e:
		error = _( 731 ) % ( _( 736 ), str ( e ) ) 
		LOG( LOG_ERROR, error )
		return False, error
Exemplo n.º 3
0
    def getfolderfilesinfo(self, folder):
        recursivefiles = []
        hashedfiles_list = []
        hashes_list = []
        self.folderfilesinfo_list = []
        try:
            if (self.connected) and (os.path.isdir(folder)):
                parser = RecursiveParser.RecursiveParser()
                recursivefiles = parser.getRecursiveFileList(
                    folder, globals.videos_ext)
                for item in recursivefiles:
                    filename = globals.EncodeLocale(os.path.basename(item))
                    filenameurl = (item)  #Corrects the accent characters.
                    if not os.path.exists(item):
                        error = _(738) % (item, )
                        LOG(LOG_ERROR, error)
                        return False, error
                    else:
                        hash = globals.hashFile(item)
                        if hash == "IOError" or hash == "SizeError":
                            error = _(739) % (
                                item,
                                hash,
                            )
                            LOG(LOG_ERROR, error)
                            return False, errors
                        else:
                            hashedfiles_list.append({
                                'filename': item,
                                'hash': hash
                            })
                            hashes_list.append(hash)
                if hashedfiles_list:
                    hashes = self.server.CheckMovieHash(
                        self.osdb_token, hashes_list)
                    for item in hashes_list:
                        for file in hashedfiles_list:
                            if file["hash"] == item:
                                f = file["filename"]
                        if hashes["data"][item]:
                            movie = hashes["data"][item]
                            self.folderfilesinfo_list.append({
                                'filename':
                                f,
                                'moviename':
                                movie['MovieName'],
                                'imdbid':
                                movie['MovieImdbID']
                            })

        except Exception, e:
            error = _(731) % (_(735), str(e))
            LOG(LOG_ERROR, error)
            return False, error
Exemplo n.º 4
0
    def getfolderfilesinfo( self, folder ):
	recursivefiles = []
	hashedfiles_list = []
	hashes_list = []
	self.folderfilesinfo_list = []
	try:
		if ( self.connected ) and ( os.path.isdir( folder ) ):
			parser = RecursiveParser.RecursiveParser()
			recursivefiles = parser.getRecursiveFileList(folder, globals.videos_ext)
			for item in recursivefiles:
				filename = globals.EncodeLocale(os.path.basename(item))
				filenameurl = (item) #Corrects the accent characters.
				if not os.path.exists(item):
					error = _( 738 ) % ( item, )
					LOG( LOG_ERROR, error )
					return False, error
				else:
					hash = globals.hashFile(item)
					if hash == "IOError" or hash == "SizeError":
						error = _( 739 ) % ( item, hash, )
						LOG( LOG_ERROR, error )
						return False, errors
					else:
						hashedfiles_list.append( {'filename':item, 'hash':hash} )
						hashes_list.append( hash )
			if hashedfiles_list:
				hashes = self.server.CheckMovieHash(self.osdb_token, hashes_list)
				for item in hashes_list:
					for file in hashedfiles_list:
						if file["hash"] == item:
							f = file["filename"]				
					if hashes["data"][item]:
						movie = hashes["data"][item]
						self.folderfilesinfo_list.append( {'filename':f, 'moviename':movie['MovieName'], 'imdbid':movie['MovieImdbID']} )
						
	except Exception, e:
		error = _( 731 ) % ( _( 735 ), str ( e ) ) 
		LOG( LOG_ERROR, error )
		return False, error