Ejemplo n.º 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')
Ejemplo n.º 2
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')
Ejemplo n.º 3
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'
Ejemplo n.º 4
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'
Ejemplo n.º 5
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 
Ejemplo n.º 6
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))
def search(list):
	dic = {}
	plot ={}
	actors={}
	director={}
	genre={}
	err_cnt = 0
	for i in list:
		try:
			obj = omdb.title(i)
			#obj2 = omdb.get(title=i,fullplot=False)
			
			if(obj != []):
				dic[i] = obj.imdb_rating
				#print(dic[i])
				plot[i] =  obj.plot
				#print(plot[i])
				actors[i]=obj.actors
				#print(actors[i])
				director[i]=obj.director
				#print(actors[i])
				genre[i]=obj.genre
				#print(actors[i])
				
		except:
			err_cnt+=1
	return (dic,plot,actors,director,genre)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
def get_movies(user_query):

    # IF INPUTTED SEARCH QUERY IS CACHED
	if user_query in CACHE_DICTION2:
		#print("\nGetting movie suggestions from cached data...")

		# GETTING WIKI SUGGESTIONS FROM CACHE DICTIONARY
		movie_data = CACHE_DICTION2[user_query]

	# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	# IF INPUTTED SEARCH QUERY IS NOT CACHED --- PULLING FROM WEB

	else:
		#print("\nRetrieving movie suggestions from web...")

		# GETTING WIKI SUGGESTIONS
		movie_data = omdb.title(user_query)

		# CACHING LIST OF SUGGESTIONS
		CACHE_DICTION2[user_query] = movie_data

	cached_suggs = open(CACHE_FNAME, 'w')
	cached_suggs.write(json.dumps(CACHE_DICTION2))
	cached_suggs.close()

	# RETURNING DICTIONARY OF SUGGESTIONS
	return movie_data
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
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
Ejemplo n.º 12
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")
Ejemplo n.º 13
0
def imdb_info(input_text):
    message_list = []
    if len(input_text) == 0:
        text = "Command format: imdb <title> [ ## <year> ]"
        message_list.append((text, []))
    else:
        text_l = input_text.split("##")
        if len(text_l) == 1:
            # title only
            om = omdb.title(text_l[0], tomatoes=True)
        else:
            # title and year
            om = omdb.title(text_l[0], year=text_l[1], tomatoes=True)

        if "title" in om.keys():
            message_list = output_movie(input_text, om)
        else:
            text = "Sorry, I can't seem to find anything for " + input_text
            message_list.append((text, []))
    return message_list
Ejemplo n.º 14
0
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)
Ejemplo n.º 15
0
    def test_get_model_fields(self):
        expected_fields = [
            'actors', 'awards', 'country', 'director', '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))
Ejemplo n.º 16
0
def plotfilm(bot, update, args):
    name = ' '.join(args)
    d = omdb.title(name, fullplot=True)
    newresponse = ''
    if len(d) != 0:
        newresponse = d['plot'] + '\nРейтинг: ' + d['imdb_rating'] + '\nЖанр: '
        newresponse += d['genre'] + '\nДлительность: '
        newresponse += d['runtime'] + '\nЯзык: '
        newresponse += d['language']
    else:
        newresponse = 'фильм не найден:('
    bot.send_message(chat_id=update.message.chat_id, text=newresponse)
Ejemplo n.º 17
0
def get_movie_cache(name):
    unique_identifier = "omdb_{}".format(name)
    if unique_identifier in OMDB_CACHE_DICTION:
        print('using cached data for movie', name)
        omdb_results = OMDB_CACHE_DICTION[unique_identifier]
    else:
        print('getting data from internet for movie', name)
        omdb_results = omdb.title(name)
        OMDB_CACHE_DICTION[unique_identifier] = omdb_results
        g = open(OMDB_CACHE_FNAME, 'w')
        g.write(json.dumps(OMDB_CACHE_DICTION))
        g.close()
    return omdb_results
Ejemplo n.º 18
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)
Ejemplo n.º 19
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")
Ejemplo n.º 20
0
def get_movie_detail(movie_obj):
    name = movie_obj.name
    api_result = omdb.title(name)
    if not api_result:
        return None
    movie_obj.plot = api_result['plot'].encode('utf-8')
    movie_obj.duration = api_result['runtime'].encode('utf-8')
    movie_obj.release_date = api_result['released'].encode('utf-8')
    movie_obj.rating = api_result['imdb_rating'].encode('utf-8')
    movie_obj.poster = api_result['poster'].encode('utf-8')
    movie_obj.cast_crew = api_result['actors'].encode('utf-8')
    movie_obj.genre = api_result['genre'].encode('utf-8')
    movie_obj.save()
    return movie_obj
Ejemplo n.º 21
0
def get_omdb_data(movie_title):
    # 		#accepts a string movie title
    # 		#check to see if there's cached data for the movie. If there is, fetch that dictionary object.
    if movie_title in CACHE_DICTION:
        print('using cached data for', movie_title)
        movie_info = CACHE_DICTION[movie_title]
    else:
        print('getting data from the internet for', movie_title)
        movie_info = omdb.title(movie_title)
        CACHE_DICTION[movie_title] = movie_info
        f = open(CACHE_FNAME, 'w')
        f.write(json.dumps(CACHE_DICTION))
        f.close()
    return movie_info
Ejemplo n.º 22
0
    def test_get_model_fields_tomatoes(self):
        expected_fields = [
            'actors', 'awards', 'country', 'director', 'genre', 'language',
            'metascore', 'plot', 'poster', 'rated', 'released', 'response',
            '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))
Ejemplo n.º 23
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
Ejemplo n.º 24
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
Ejemplo n.º 25
0
def search(movies):
    dic = {}
    for movie in movies:
        #print(movie)
        if len(movie) <= 3:
            continue
        try:
            obj = omdb.title(movie)
            #print(obj)
            if (obj != []):
                dic[movie] = obj.imdb_rating
                #print (obj)
            pass
        except:
            pass  #print("Error establishing connection\n")

    return (dic)
Ejemplo n.º 26
0
def load_csv_and_query(input_file):
    #load csv and iterate through df to get movie names
    master_data = pd.read_csv(input_file, sep='\t')
    #print(movies_list)
    movies_list = master_data['Movie'].tolist()
    print(movies_list)
    for movie in movies_list:
        try:
            movie_deets = omdb.title(movie, timeout=5)
            if movie_deets:
                time.sleep(2)
                continue
            else:
                print("Error - {}\n".format(movie))
        except requests.exceptions.RequestException as inst:
            print('Error - {} Movie - {}\n'.format(inst, movie))
    time.sleep(2)
Ejemplo n.º 27
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)
Ejemplo n.º 28
0
def get_movies_info(movie_list, top_window):
    ratings = {}
    box_office = {}
    release_date = {}
    length = {}
    votes_number = {}
    full_title = {}
    movies_not_recognized = []

    current_movie_indicator = Text(top_window)
    current_movie_indicator.config(width=30, height=5)
    current_movie_indicator.grid()
    top_window.update_idletasks()

    for movie_name in movie_list:
        current_movie_indicator.insert(END, "Analyzing: " + movie_name)
        top_window.update_idletasks()

        try:
            movie = omdb.title(movie_name)
            if movie:
                ratings[movie_name] = movie.imdb_rating
                box_office[movie_name] = movie.box_office
                release_date[movie_name] = movie.released
                length[movie_name] = movie.runtime
                votes_number[movie_name] = movie.imdb_votes
                full_title[movie_name] = movie.title
            else:
                movies_not_recognized.append(movie_name)

            current_movie_indicator.delete("1.0", END)
        except Exception as exception:
            print("Exception error: " + str(exception))

    movie_informations = {
        'Ratings': ratings,
        'Box_office': box_office,
        'Release_date': release_date,
        'Length': length,
        'Votes_number': votes_number,
        'Full_title': full_title,
        'Not_recognized': movies_not_recognized
    }
    current_movie_indicator.destroy()
    return movie_informations
Ejemplo n.º 29
0
def get_movie_info(start_id, end_id):
    omdb.set_default('plot', True)
    sub_query = Movie.objects.filter(movie_id__gte=start_id).filter(
        movie_id__lt=end_id)
    for q in sub_query:
        title = q.name.encode('utf-8')
        api_result = omdb.title(title)
        if api_result:
            q.plot = api_result['plot'].encode('utf-8')
            q.duration = api_result['runtime'].encode('utf-8')
            q.release_date = api_result['released'].encode('utf-8')
            q.rating = api_result['imdb_rating'].encode('utf-8')
            q.poster = api_result['poster'].encode('utf-8')
            q.cast_crew = api_result['actors'].encode('utf-8')
            q.genre = api_result['genre'].encode('utf-8')
            q.save()
        else:
            print('cannot retrieve data of movie  ' + title)
Ejemplo n.º 30
0
def add_movie():

    while True:

        print("'Enter' to continue, to end session type 'end!'")
        action = input()
        if action != "end!":
            print("Enter Movies Name")
            movies = []
            movie = input()
            splt_movie = movie.split(", ")
            order = movie.rsplit(None, 1)[-1]
            for i in range(len(splt_movie)):
                new_element = splt_movie[i]
                movies.append(new_element)
                print(movies)
            for each in movies:
                print(omdb.title(each))
        else:
            print("bye")
            break
Ejemplo n.º 31
0
 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()
Ejemplo n.º 32
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
Ejemplo n.º 33
0
def get_imdb_info(query):
    """
    Gathers all imdb info on a movie/tv show
    """
    search = omdb.search(query)
    imdb_info = {}

    try:
        search = search[0].title
    except IndexError:
        print('An exception occured while searching for query')
    else:
        search_result = omdb.title(search)
        imdb_info = {
            'title': search_result.title,
            'cast': search_result.actors,
            'genre': search_result.genre,
            'plot': search_result.plot,
            'rating': search_result.imdb_rating,
            'poster': search_result.poster,
            'writer': search_result.writer,
        }

    return imdb_info
Ejemplo n.º 34
0
    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))
Ejemplo n.º 35
0
import omdb
from data_manager import insert_data
from data_manager import title_is_in_database

title = raw_input('Nome do filme/seriado: ')

omdb_info = omdb.title(title)

if len(omdb_info) == 0:
    print 'Informacoes nao encontradas.'
    exit()

print "Informacoes encontradas:"
print omdb_info

if title_is_in_database(omdb_info['title']) == True:
    print "\nEsse filme/seriado ja esta no banco de dados. Saindo..."
    exit()

who = raw_input("\nQuem assistiu a esse filme? ")

insert_data(who, omdb_info)
 def com_omdb_title(self, media_title):
     """
     Grab by title
     """
     omdb.title(media_title)
Ejemplo n.º 37
0
if user_choice == "type":
    print(
        "\nYou can additionally sort the movies by: rating, popularity, length and release date.\n"
    )
    print(
        "If you want to do so simply add ' : sorting option' after typing titles.\n"
    )
    user_type = input("Type movie title(s) separated by coma and space: ")
    sorting = user_type.split(" : ")
    titles = sorting[0].split(", ")
    if len(sorting) > 1:
        sorting = sorting[1]
    else:
        sorting = "No sorting"
else:
    get_correct_title()

for title in titles:
    result = omdb.title(title)
    if not result:
        result['title'] = title
        result['error'] = True
    results.append(result)
if user_choice == "type":
    function_sort(sorting)
for result in results:
    if 'error' in result:
        print(f"No movie found with the title: {result['title']} ")
    else:
        print_movie_information()
Ejemplo n.º 38
0
def test_empty_data():
    invalid = 'asdfghjkl'

    assert omdb.search(invalid) == []
    assert omdb.title(invalid) == {}
    assert omdb.imdbid(invalid) == {}
Ejemplo n.º 39
0
def movieInfo(movie_name):
    movie = omdb.title(movie_name)
    printInfo(movie, movie_name)
Ejemplo n.º 40
0
def getMovie(movieName):
	movie = omdb.title(movieName)
	return movie;
Ejemplo n.º 41
0
def getMovie(movieName):
	movie = omdb.title(movieName,tomatoes=True)
	return movie;
Ejemplo n.º 42
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)
Ejemplo n.º 43
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:
Ejemplo n.º 44
0
def test_title():
    t = 'True Grit'
    result = omdb.title(t)

    assert result['title'] == t
Ejemplo n.º 45
0
key = "60f61a52"
omdb.set_default('apikey', key)

with open(og_csv) as already_done:
    dr = csv.DictReader(already_done)
    already_have = [x['title'] for x in dr]

already_have = set(already_have)
movies_to_try = [x for x in movies_to_try if not x in already_have]

counter = 1
for m in movies_to_try:
    print(f'movie: {m}')
    movie_dict = {}
    try:
        res = omdb.title(m, fullplot=True)
        movie_dict['title'] = res['title']
        movie_dict['genre'] = res['genre']
        movie_dict['plot'] = res['plot']
        df = pd.DataFrame([movie_dict], columns=movie_dict.keys())
        output_path = os.path.join('.', 'movie_data.csv')
        genres = [
            x.lower() if not x.endswith(',') else x[:-1].lower()
            for x in movie_dict['genre'].split()
        ]
        plot = movie_dict['plot'].split()

        #OG FILTER
        if ('adult' in genres or 'biography' in genres
                or 'documentary' in genres) and len(plot) <= 30:
            continue
Ejemplo n.º 46
0
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()
	
Ejemplo n.º 47
0
	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))			
Ejemplo n.º 48
0
    def test_title(self):
        t = 'True Grit'
        data = omdb.title(t)

        self.assertEqual(data.title, t)
Ejemplo n.º 49
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)
Ejemplo n.º 50
0
    def test_empty_data(self):
        invalid = 'asdfghjkl'

        self.assertEqual(omdb.search(invalid), [])
        self.assertEqual(omdb.title(invalid), {})
        self.assertEqual(omdb.imdbid(invalid), {})
Ejemplo n.º 51
0
    def test_empty_data(self):
        invalid = 'asdfghjkl'

        self.assertEqual(omdb.search(invalid), [])
        self.assertEqual(omdb.title(invalid), {})
        self.assertEqual(omdb.imdbid(invalid), {})
Ejemplo n.º 52
0
        for index, movie in enumerate(titles):
            for word in WordsToDelete:
                movie = movie.replace(word, "")
            titles[index] = movie
        for index, movie in enumerate(titles):
            titles[index] = movie.split(" .")[0].strip()

    if not TitleFromFIle and re.findall(r',', title):
        if re.findall(r':', title):
            titles = title.split(' : ')  #
            rating = titles[1]  #
            title = titles[0]  #
        titles = title.split(', ')  #
        for movie in titles:  #
            SortedMovies.append(movie)
            results = omdb.title(movie)  #
            if not results:
                print("Wrong movie")
                continue
            MovieDickt[movie] = results
    elif TitleFromFIle:
        for movie in titles:  #
            SortedMovies.append(movie)
            results = omdb.title(movie)  #
            if not results:
                print("Wrong movie")
                continue
            MovieDickt[movie] = results
    else:
        results = omdb.title(title)  #
        MovieDickt[title] = results
Ejemplo n.º 53
0
import datetime

API_KEY = "ed573f66"

omdb.set_default('apikey', API_KEY)

forbiddenCharacters = [':', '?', '<', '>', '|', '"', '\\', '/', '*']
print("Write movie titles: ")
title = input()
titles = []
if re.findall(r',', title):
    titles = title.split(", ")
else:
    titles.append(title)
for movie in titles:
    results = omdb.title(movie)
    title = results['title']
    for character in title:
        if character in forbiddenCharacters:
           title = title.replace(character,"")
    if not len(title):
        print("Write name of your folder: ")
        title = input()
    newpath = f"C:/Movies/{title}"
    if not os.path.exists(newpath):
        os.makedirs(newpath)
    fout = open(f"{newpath}/{title}.txt",'w')
    fout.write("Title: " + results['title'] + "\n")
    fout.write("Rating: " + results['imdb_rating']+ "\n")
    fout.write("Runtime: " + results['runtime']+ "\n")
    if results['released'] == "N/A":