Exemple #1
0
    def test_set_default(self):
        t = 'True Grit'

        self.assertEqual(omdb.title(t).year, '2010')

        omdb.set_default('year', '1969')

        self.assertEqual(omdb.title(t).year, '1969')
Exemple #2
0
def test_set_default():
    t = 'True Grit'

    result = omdb.title(t)
    assert result['year'] == '2010'

    omdb.set_default('year', '1969')

    result = omdb.title(t)
    assert result['year'] == '1969'
Exemple #3
0
def details(title):
    """Print the details of the given film (specified by title) to the console"""
    rf = omdb.title(title, tomatoes=True)
    
                
    r = ASCIIProxy(rf)
    print
    print "-"*76
    print "%s %15s %3s [%s] %7s" % (colorama.Fore.BLACK + colorama.Back.WHITE+("%-51s"%r.title)+colorama.Back.BLACK + colorama.Fore.WHITE, colorama.Fore.RED+r.rated+colorama.Fore.WHITE, r.runtime, colorama.Fore.GREEN+r.year+colorama.Fore.WHITE, r.type.upper())    
    
    print "%-21s" % (colorama.Style.BRIGHT + r.director + colorama.Style.NORMAL )
    print "%-46s %s/%s" % (r.genre, r.country, r.language)
    print "-"*76
    print "%76s" % (r.actors)
    print
    if len(r.awards)>0:
        print colorama.Style.BRIGHT + "> " + r.awards + " <" + colorama.Style.NORMAL    
    print
    print colorama.Fore.YELLOW + textwrap.fill(r.plot, width=76) + colorama.Fore.WHITE
    print
    print colorama.Fore.WHITE + textwrap.fill(r.tomato_consensus, width=76) + colorama.Fore.WHITE
    print
    print "     Meta  ", stars(r.metascore,100),    "     IMDB       ", stars(r.imdb_rating,10)
    print "     Tomato", stars(r.tomato_rating,10), "     Tomatometer", stars(r.tomato_meter,100)
    print "User Tomato", stars(r.tomato_user_rating,5), "User Tomatometer", stars(r.tomato_user_meter,100),
    print 
Exemple #4
0
def test_get_fields():
    expected_fields = [
        'actors',
        'awards',
        'box_office',
        'country',
        'director',
        'dvd',
        'genre',
        'language',
        'metascore',
        'plot',
        'poster',
        'production',
        'rated',
        'ratings',
        'released',
        'response',
        'runtime',
        'title',
        'type',
        'website',
        'writer',
        'year',
        'imdb_id',
        'imdb_rating',
        'imdb_votes'
    ]

    result = omdb.title('True Grit')
    assert set(result.keys()) == set(expected_fields)

    result = omdb.imdbid('tt0065126')
    assert set(result.keys()) == set(expected_fields)
Exemple #5
0
    def test_get_model_fields(self):
        expected_fields = [
            'actors',
            'awards',
            'director',
            'country',
            'genre',
            'language',
            'metascore',
            'plot',
            'poster',
            'rated',
            'released',
            'response',
            'runtime',
            'title',
            'type',
            'writer',
            'year',
            'imdb_id',
            'imdb_rating',
            'imdb_votes'
        ]

        self.assertEqual(set(omdb.title('True Grit').keys()),
                         set(expected_fields))
        self.assertEqual(set(omdb.imdbid('tt0065126').keys()),
                         set(expected_fields))
Exemple #6
0
def add_genre(page):
    if gen_d.has_key(page):
        return gen_d[page]
    else:
        title = re.split(r'([A-Z][a-z]*)', page)
        o_title = omdb.title(title)
        gen = ""
        if o_title:
            gen = o_title['genre']
        gen_d[page] = gen
        return gen
def search(list):
	dic = {}
	err_cnt = 0
	for i in list:
		try:
			obj = omdb.title(i)
			if(obj != []):
				dic[i] = obj.imdb_rating
		except:
			err_cnt+=1
	return (dic)
Exemple #8
0
 def do_activate(self, args, argv):
    movie = omdb.title(' '.join(args).strip())
    print("Name : "+movie.title)
    print("Year of Releasing : "+movie.year)
    print("Movie or Series : "+movie.type)
    print("Genre : "+movie.genre)
    print("Cast : "+movie.actors)
    if (float(movie.imdb_rating) < 5.0):	
           print("I Won't Watch This Because its only "+movie.imdb_rating+" on imdb")
    else:
           print("Ok I will watch it because it got "+movie.imdb_rating+" on imdb")
Exemple #9
0
def year(filename):

    ret = None

    title_search = omdb.title(filename)
    if len(title_search) > 0:
        ret = title_search['year']
    else:
        movie_search = omdb.search_movie(filename)
        if len(movie_search) > 0:
            ret = movie_search[0]['year']
        else:
            print('Could not find year for "{0}"'.format(filename))

    return ret
Exemple #10
0
def test_get_tomatoes_fields():
    expected_fields = [
        'actors',
        'awards',
        'box_office',
        'country',
        'director',
        'dvd',
        'genre',
        'language',
        'metascore',
        'plot',
        'poster',
        'production',
        'rated',
        'ratings',
        'released',
        'response',
        'runtime',
        'title',
        'type',
        'website',
        'writer',
        'year',
        'imdb_id',
        'imdb_rating',
        'imdb_votes',
        'tomato_consensus',
        'tomato_fresh',
        'tomato_image',
        'tomato_meter',
        'tomato_rating',
        'tomato_reviews',
        'tomato_rotten',
        'tomato_url',
        'tomato_user_meter',
        'tomato_user_rating',
        'tomato_user_reviews'
    ]

    result = omdb.title('True Grit', tomatoes=True)
    assert set(result.keys()) == set(expected_fields)

    result = omdb.imdbid('tt0065126', tomatoes=True)
    assert set(result.keys()) == set(expected_fields)
 def get_movie_metadata_from_omdb(self):
     """
     Gets the movie metadata from the OMDb API (http://www.omdbapi.com/)
     """
     movie = omdb.title(self.title, tomatoes=True)
     if movie:
         self.year = movie.year[:4]
         self.genre = movie.genre
         self.imdb_rating = movie.imdb_rating
         self.imdb_id = movie.imdb_id
         if movie.runtime != "N/A":
             self.runtime = movie.runtime.split(" ")[0]
         self.plot = movie.plot
         if "http" in movie.poster:
             poster_data = requests.get(movie.poster)
             file_extension = os.path.splitext(movie.poster)[1]
             self.poster.save(
                 slugify(self.title) + file_extension,
                 ContentFile(poster_data.content),
             )
         self.save()
Exemple #12
0
def generateData(titles):

	total = len(titles)
	size=30
	data = []
	print "Downloading data for " + str(len(titles)) + " movies..."

	for i,movie in enumerate(titles):
		response = omdb.title(movie[0],year=movie[1], tomatoes=True)
		if response:
			if response['tomato_rating'] != 'N/A':
				FA = FARating(movie[0],movie[1])
				response['FA_rating']=str(FA)
				response['user_rating'] = movie[2]
				data.append(response) 
		progress = (i+1.0)/total
		sys.stdout.write("\r[" + "=" * (int(round((progress*size)))-1) +">" +  " " * int(round((1-progress)*size)) 
						+ "] "+ str(i+1) + "/" + str(total))
		sys.stdout.flush()
		
	print
	return data
    def test_get_model_fields_tomatoes(self):
        expected_fields = [
            'actors',
            'director',
            'genre',
            'plot',
            'poster',
            'rated',
            'released',
            'runtime',
            'title',
            'type',
            'writer',
            'year',
            'imdb_id',
            'imdb_rating',
            'imdb_votes',

            'box_office',
            'dvd',
            'production',
            'website',
            'tomato_consensus',
            'tomato_fresh',
            'tomato_image',
            'tomato_meter',
            'tomato_rating',
            'tomato_reviews',
            'tomato_rotten',
            'tomato_user_meter',
            'tomato_user_rating',
            'tomato_user_reviews'
        ]

        self.assertEqual(set(omdb.title('True Grit', tomatoes=True).keys()), set(expected_fields))
        self.assertEqual(set(omdb.imdbid('tt0065126', tomatoes=True).keys()), set(expected_fields))
def getMovie(movieName):
	movie = omdb.title(movieName)
	return movie;
Exemple #15
0
    def test_empty_data(self):
        invalid = 'asdfghjkl'

        self.assertEqual(omdb.search(invalid), [])
        self.assertEqual(omdb.title(invalid), {})
        self.assertEqual(omdb.imdbid(invalid), {})
Exemple #16
0
    def test_title(self):
        t = 'True Grit'
        data = omdb.title(t)

        self.assertEqual(data.title, t)
def saveReleased(movie,fo):
	released = movie.released
	fo.write('\nreleased='+str(released))
	return;

#open up the input and output files
f = open('top250.txt', 'r')
fo = open("stored250.txt", "a")
#erase the output
fo.seek(0)
fo.truncate()

#go through the list of 250 movie titles
for line in f:
	try:
		movie = omdb.title(line)
		print movie.title
		print movie.director
		saveTitle(movie,fo)
		saveDirector(movie,fo)
		savePoster(movie,fo)
		saveActors(movie,fo)
		saveRating(movie,fo)
		saveGenre(movie,fo)
		saveReleased(movie,fo)
	except:
		print''

f.close()
fo.close()
	
 def com_omdb_title(self, media_title):
     """
     Grab by title
     """
     omdb.title(media_title)
	def buscar_no_imdb(self, nome, nomeOriginal, url, legenda, ehtorrent, temporada, episodio):
		try:
			informacoesSeriadoJaBuscadoIMDB = False
			informacoesSeriadoBuscadasIMDBEEpisodioAdicionado = False
			for movie_serie_full in self.__filmes_seriados_full:
				if movie_serie_full['nome_original'] == nomeOriginal:
					print('O filme/serie ja buscou pelo menos uma vez informacoes do IMDB: {}'.format(nomeOriginal))
					informacoesSeriadoJaBuscadoIMDB = True
					break

			if informacoesSeriadoJaBuscadoIMDB:
				for movie_serie_full in self.__filmes_seriados_full:
					if movie_serie_full['nome_original'] == nomeOriginal and movie_serie_full['temporada'] == temporada and movie_serie_full['episodio'] == episodio:						
						informacoesSeriadoBuscadasIMDBEEpisodioAdicionado = True
						break

			if not informacoesSeriadoBuscadasIMDBEEpisodioAdicionado and informacoesSeriadoJaBuscadoIMDB:				
				
				for movie_serie_full in self.__filmes_seriados_full:
					if nomeOriginal == movie_serie_full['nome_original']:
						print('Seriado no imdb, mas episodio {0} nao adicionado '.format(episodio))						
						episodio_dict = dict()			
						episodio_dict['url'] = url
						episodio_dict['nome'] = nome
						episodio_dict['nome_original'] = nomeOriginal										
						episodio_dict['legenda'] = legenda
						episodio_dict['ehtorrent'] = ehtorrent
						episodio_dict['temporada'] = temporada
						episodio_dict['episodio'] = episodio
						episodio_dict['imdb'] = movie_serie_full['imdb']						
						self.__filmes_seriados_full.append(episodio_dict)								
						break
					

			if not informacoesSeriadoJaBuscadoIMDB and not informacoesSeriadoBuscadasIMDBEEpisodioAdicionado:				
				if self.__erros_imdb < 100:	
					print('Buscando filme: {0}'.format(nomeOriginal))		
					movie_serie_full = dict()			

					if self.url_filme_serie_funcionando(url):
						movie_serie_full['imdb'] = omdb.title(nomeOriginal)
						if len(movie_serie_full['imdb']) > 0:
							print('')
							print(movie_serie_full['imdb'])
							print('')
							movie_serie_full['url'] = url
							movie_serie_full['nome'] = nome
							movie_serie_full['nome_original'] = nomeOriginal											
							movie_serie_full['legenda'] = legenda
							movie_serie_full['ehtorrent'] = ehtorrent
							movie_serie_full['temporada'] = temporada
							movie_serie_full['episodio'] = episodio			
							print('PRINCIPAIS INFORMACOES DO IMDB: NOME: {0} | GENEROS: {1} | IMDB_CLASS.{2}'.format(movie_serie_full['imdb'].title, movie_serie_full['imdb'].genre, movie_serie_full['imdb'].imdb_rating))
							print('POSTER: {}'.format(movie_serie_full['imdb'].poster))
							self.__filmes_seriados_full.append(movie_serie_full)
							time.sleep(0.001)
						else:
							print('FILME NAO ENCONTRADO NO IMDB: {}'.format(nomeOriginal))
					else:
						LinksFilme.objects.filter(link=url).delete()						
						LinksEpisodioSeriado.objects.filter(link=url).delete()						
						Filme.objects.filter(titulo_ingles=nomeOriginal).delete()
						Episodio.objects.filter(titulo='Episodio {0} da {1} temporada'.format(episodio, temporada)).delete()
						print('URL: {0} do FILME {1} inacessivel'.format(url, nomeOriginal))
						# IMPLEMENTAR ATUALIZACAO PARA INVALIDAR O LINK NO BANCO LOCAL
				else:
					time.sleep(0.001)
					print('Falhas consecutivas impedem a busca no IMDB [SINCRONIZACAO COM IMDB SERA REALIZADA EM OUTRO MOMENTO]')
		except Exception, e:
			self.__erros_imdb += 1
			print('{0} Falhas ao buscar filme/seriado no IMDB: {1}'.format(self.__erros_imdb, str(e)))			
			print('Nome do filme utilizado na pesquisa que FALHOU: {}'.format(nomeOriginal))			
Exemple #20
0
def test_title():
    t = 'True Grit'
    result = omdb.title(t)

    assert result['title'] == t
def getMovie(movieName):
	movie = omdb.title(movieName,tomatoes=True)
	return movie;
Exemple #22
0
            cmd = default_path_for_music
            print cmd
            try:
                os.makedirs(cmd, 0755)
            except OSError as e:
                if e.errno == 17:
                    os.chmod(cmd, 0755)
            shutil.move(path, destination)
            #adding the attribute
           # xattr.setxattr(destination, 'user.fpath', valueofsetx)
            print 'file moved to dir: ', destination

    elif mimetype == 'video':
        f = guessit(fname)
        extension = fname.rsplit('.', 1)
        getdata = omdb.title(f['title'])
        if getdata.type == 'movie':
            newfilename = str(getdata.title)+'.'+extension[1]
            valueofsetx = '/movies/' + getdata.genre+'/'+str(getdata.title)+'.'+extension[1]
            valueofsetx_withoutfilename = '/movies/' + getdata.genre+'/'
            default_path_for_movies = rootdir + valueofsetx_withoutfilename
            destination = default_path_for_movies
            if path != destination:
                cmd = default_path_for_movies
                try:
                    os.makedirs(cmd, 0755)
                except OSError as e:
                    print e
                    if e.errno == 17:
                        os.chmod(cmd, 0755)
                try:
Exemple #23
0
def get_movie_info(movie_name):
    omdb.set_default('tomatoes', True)
    movie_obj = omdb.title(movie_name)
    for category,info in movie_obj.iteritems():
        print "{0}{1}{2}".format(category.upper(),' : ',info)
Exemple #24
0
def test_empty_data():
    invalid = 'asdfghjkl'

    assert omdb.search(invalid) == []
    assert omdb.title(invalid) == {}
    assert omdb.imdbid(invalid) == {}