def test_get_all_movies(self): set_1 = Movie( 28, 'Apocalypse Now', '1979-08-15', 'At the height of the Vietnam war, Captain Benjamin Willard is sent on a dangerous mission that, officially, "does not exist, nor will it ever exist." His goal is to locate - and eliminate - a mysterious Green Beret Colonel named Walter Kurtz, who has been leading his personal army on illegal guerrilla missions into enemy territory.' ) set_2 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.insert_movie(self, set_1) database_workclass.insert_movie(self, set_2) movie_list = database_searchs.get_all_movies(self) sets = [ Movie( 28, 'Apocalypse Now', '1979-08-15', 'At the height of the Vietnam war, Captain Benjamin Willard is sent on a dangerous mission that, officially, "does not exist, nor will it ever exist." His goal is to locate - and eliminate - a mysterious Green Beret Colonel named Walter Kurtz, who has been leading his personal army on illegal guerrilla missions into enemy territory.' ), Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) ] for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview) database_workclass.delete_movie(self, set_1.movie_id) database_workclass.delete_movie(self, set_2.movie_id)
def test_bring_movies_list_from_DB_(self, get_all_movies): movie_list = data_getter_from_database.get_all_movies_from_db(self) sets = [ Movie(1, 'Spider-Man', '2002', 'Really cool movie'), Movie(2, 'Scarface', '1983', 'Retro movie') ] for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview)
def load_from_xmltv(self, channel_id, day_text): ''' ''' var_url = urlopen('https://xmltv.xmltv.se/' + channel_id + '_' + day_text + '.xml') epg_xml = parse(var_url) result = [] count = 0 for programme in epg_xml.iterfind('programme'): provider = self.get_attrib(programme, 'channel') start = self.string_to_timestamp( self.get_attrib(programme, 'start')) stop = self.string_to_timestamp(self.get_attrib(programme, 'stop')) title = self.get_text(programme.find('title'), '') desc = self.get_text(programme.find('desc'), '') category = self.get_text(programme.find('category'), '') episode = programme.find('episode-num') episode_num = None channel_info = self.search_channel_info(provider) url = None media_type = None if channel_info: url = channel_info['url'] media_type = channel_info['mediatype'] if episode: num_system = self.get_attrib(episode, 'system') if num_system == 'xmltv_ns': episode_num = self.get_text(episode) count += 1 plugin_name = self.plugin_names[0] self.providers.add(provider) self.categories.add(category) new_movie = Movie(source=plugin_name, source_type=defaults.MOVIE_TYPE_STREAM, provider=provider, category=category, title=title, timestamp=str(int(start)), duration=stop - start, description=desc, url=url) new_movie.add_stream(media_type, '', url) if not plugin_name in self.movies: self.movies[plugin_name] = {} self.movies[plugin_name][new_movie.uri()] = new_movie movie_info = MovieInfo.movie_to_movie_info(new_movie, category) movie_info['recordable'] = True result.append(movie_info) print("epg loaded, {0} entries".format(count)) return result
def test_bring_movies_list_api(self, search_movie_by_title): set_1 = Movie(1, 'Spider-Man', '2002', 'Really cool movie') set_2 = Movie(2, 'Scarface', '1983', 'Retro movie') sets = [] sets.append(set_1) sets.append(set_2) movie_list = data_getter_from_api.get_movie_by_title(self, 'Mokceado') for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview)
def test_delete_movie(self): set_2 = Movie( 105, 'Back to the Future', '1985-07-03', "Eighties teenager Marty McFly is accidentally sent back in time to 1955, inadvertently disrupting his parents' first meeting and attracting his mother's romantic interest. Marty must repair the damage to history by rekindling his parents' romance and - with the help of his eccentric inventor friend Doc Brown - return to 1985." ) database_workclass.insert_movie(self, set_2) database_workclass.delete_movie(self, 105) set_1 = Movie('0', 'Not found', 'No data', 'No data') film = database_searchs.search_movie_by_id(self, 105) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview)
def runManager(): newMovie = Movie() newMovie.addMovie() newMovie.getIDs() newMovie.getProviders() print(newMovie.availServs)
def test_write_to_disk(): expected_json = { "actor": "Bruce Willis", "movies": [ {"title": "The Godfather", "year": "1972"}, {"title": "The Shawshank Redemption", "year": "1994"}, ], } actor = Actor("Bruce Willis", "/name/nm0000246/", "Actor", "Die Hard") movies = [Movie("The Shawshank Redemption", "1994"), Movie("The Godfather", "1972")] write_to_disk(actor, movies, -1) with open("Bruce Willis-2001-01-01 01:01:01.json", "r") as f: actual_json = json.loads(f.read()) assert actual_json == expected_json os.remove("Bruce Willis-2001-01-01 01:01:01.json")
def test_get_movies(mock_retrieve_movies): actor = Actor("Bruce Willis", "/name/nm0000246/", "Actor", "Die Hard") expected_first = Movie("McClane", "Upcoming") expected_last = Movie("The First Deadly Sin", "1980") expected_num_movies = 125 actual_movies = get_movies(actor) assert actual_movies[0].title == expected_first.title assert actual_movies[0].year == expected_first.year assert actual_movies[len(actual_movies) - 1].title == expected_last.title assert actual_movies[len(actual_movies) - 1].year == expected_last.year assert len(actual_movies) == expected_num_movies
def test_bring_movie_from_api_no_existente(self): set_1 = Movie(31241232351234324, 'None', 'None', 'None') film = data_getter_from_api.get_movie(self, 31241232351234324) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(str(film.title), set_1.title) self.assertEqual(str(film.date_of_release), set_1.date_of_release) self.assertEqual(str(film.overview), set_1.overview)
def get_movies(actor): """ input: actor, an instance of Actor returns: movies, list of Movie objects """ raw_html = imdb_calls.retrieve_movies(actor.slug) # the returned HTML from the page is not nicely broken into a parent-children # structure for the lists of films under the actor/producer/... sections # so we forceably cut out everything before and after the actor tag before # putting it into beautiful soup start_cut_index = raw_html.find('<a name="actor">Actor</a>') if start_cut_index == -1: start_cut_index = raw_html.find('<a name="actress">Actress</a>') trimmed_html = raw_html[start_cut_index:] # skip the first 12 chars, since they already match end_cut_index = trimmed_html[12:].find('<a name="') trimmed_html = trimmed_html[0:end_cut_index] bs = BeautifulSoup(trimmed_html, features="html.parser") movies = [] for movie in bs.find_all(class_="filmo-row"): title = movie.a.string year = movie.span.string.strip() if len(year) == 0: year = "Upcoming" movies.append(Movie(title, year)) return movies
def test_bring_movie_from_api(self, search_movie_by_id): set_1 = Movie(1, 'Spider-Man', '2002', 'Really cool movie') film = data_getter_from_api.get_movie(self, 1) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview)
def test_bring_movie_from_api_not_exist(self, search_movie_by_id): set_1 = Movie(0, 'no found', 'no data', 'no data') film = data_getter_from_api.get_movie(self, 0) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview)
def test_insert_movie(self): set_2 = Movie( 238, 'The Godfather', '1972-03-14', 'Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.' ) database_workclass.insert_movie(self, set_2) set_1 = Movie( 238, 'The Godfather', '1972-03-14', 'Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.' ) film = database_searchs.search_movie_by_id(self, 238) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) database_workclass.delete_movie(self, 238)
def loadChannels(self): plugin_name=self.plugin_names[0] source_type=defaults.MOVIE_TYPE_STREAM try: with open(os.path.join( self.origin_dir,self.config.read('channel_file'))) as fd: root = xmltodict.parse(fd.read()) for track in root['playlist']['trackList']['track']: provider=track['title'] #print (track['album']) location=track['location'] url_st=urlparse(location) full_url = urlunparse(( #url_st.scheme, self.config.read('scheme'), #url_st.netloc, self.config.read('netloc'), url_st.path, url_st.params, url_st.query, url_st.fragment, )) #print(full_url) self.providers.add(provider) new_movie = Movie( source=plugin_name, source_type=source_type, provider=provider, category='live', title=provider+" Live", timestamp="0", duration=0, description='', url=full_url ) new_movie.add_stream('ts','',full_url) if not plugin_name in self.movies: self.movies[plugin_name]={} self.movies[plugin_name][new_movie.uri()]=new_movie except Exception as e: print(str(e))
def parse_movie_title(): movie_map = {} for line in open("cornell-movie-dialogs-corpus/movie_titles_metadata.txt"): cats = line.split(" +++$+++ ") m_id = cats[0].strip().lower() title = cats[1].strip().lower() year = cats[2].strip().lower() rating = cats[3].strip().lower() num_votes = cats[4].strip().lower() # genre parsing genre_string = cats[5][2:-3] genres = set(genre_string.split("', '")) # add to movie map movie = Movie(m_id, title, year, rating, num_votes) movie.set_genres(genres) movie_map[m_id] = movie return movie_map
def test_bring_movie_from_api_inte(self): set_1 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) film = data_getter_from_api.get_movie(self, 76341) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview)
def test_update_movie(self): set_2 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.insert_movie(self, set_2) set_3 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.update_movie(self, set_3) set_1 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) film = database_searchs.search_movie_by_id(self, 76341) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) database_workclass.delete_movie(self, set_3.movie_id)
def loadChannels(self): for server in self.serverConfig: try: f = requests.get(server['url']) content=f.text match = re.search(r'<ol class="items">(.*)</ol>',content,re.DOTALL) if match: lines=match.group(1).split('\n') item_regex=re.compile(r'<li value=".*"><a href="(.*)" vod tvid=".*">(.*)</a>') plugin_name=self.plugin_names[0] source_type=defaults.MOVIE_TYPE_STREAM with self.lock: for line in lines: item_match=re.search(item_regex,line) if item_match: full_url=urljoin(server['url'],item_match.group(1)) provider=item_match.group(2) self.providers.add(provider) new_movie = Movie( source=plugin_name, source_type=source_type, provider=provider, category='live', title=provider+" Live", timestamp="0", duration=0, description='', url=full_url ) new_movie.add_stream('ts','',item_match.group(1)) if not plugin_name in self.movies: self.movies[plugin_name]={} self.movies[plugin_name][new_movie.uri()]=new_movie except Exception as e: print(str(e))
def process_filenames(files, vid_type, output_dir): """ Takes a list of files and passes their names to confirmTitle to try and get the actual movie title before copying the file to a the 'clean_titles' directory. Creating said directory if necessary. :param files: List of files to check :param vid_type: Either "movies" or "series" """ osmakedirs(output_dir, exist_ok=True) for file in files: vid_type = file.split("/")[1].lower() vid_obj = Series(file) if vid_type.lower() == "tv" else Movie(file) # This will have to be changed later to grab the torrent files as they finish new_path = ospathjoin(output_dir, vid_obj.path) if not osisdir(osdirname(new_path)): osmakedirs(osdirname(new_path), exist_ok=True) copy2(file, new_path) log_msg("info", "CLEANED: '{}' has been renamed to '{}'.".format(osbasename(file), vid_obj.file_name)) log_msg("info", "NEW_PATH: '{}'".format(new_path))
def query_handler(self, queue_event, max_result_count): ''' try to send simulated answers ''' # print("hd_recorder query handler", queue_event.type, queue_event.user, max_result_count) if queue_event.type == defaults.QUERY_MOVIE_ID: new_uri = queue_event.params for record_movie in self.records.read( 'all', {}).values(): # 'all': read the whole config if record_movie['new_uri'] == new_uri: return [ Movie(source=self.plugin_names[0], source_type=defaults.MOVIE_TYPE_RECORD, provider=self.plugin_names[0], category=record_movie['category'], title=record_movie['title'], timestamp=record_movie['timestamp'], duration=record_movie['duration'], description=record_movie['description'], url=record_movie['new_url']) ] return []
def DeleteFromWatchedList(username, movieid): movieToDelete = WatchedList(username, movieid, "") score = movieToDelete.existsInWatchedList() movieToDelete = WatchedList(username, movieid, score) movieToDelete.delete_from_watched_list() movie = Movie("", "", "", "", "") oldvotes = movie.getvotes_in_movie_db(movieid) oldscore = movie.getscore_in_movie_db(movieid) if int(oldvotes[0]) > 1: total = int(oldvotes) * int(oldscore) total = total - score newvotes = oldvotes - 1 newscore = total / newvotes movie.update_votes_and_score(movieid, newscore, newvotes) return redirect(url_for('page.home_page'))
def load_filmlist(self, file_name): print(os.path.abspath(file_name)) try: # does the file exist at all already? filmlist_time_stamp = os.path.getmtime(file_name) except: filmlist_time_stamp = 0 print("timestamp", filmlist_time_stamp, time.time()) if filmlist_time_stamp < time.time( ) - 60 * 60 * 48: # file is older as 48 hours print("Retrieve film list") try: var_url = urlopen('https://res.mediathekview.de/akt.xml') server_list = parse(var_url) print(server_list) url = None prio = 999 # dummy start value for item in server_list.iterfind('Server'): this_prio = int(item.findtext('Prio')) if this_prio < prio: # filter for the server with the lowest prio prio = this_prio url = item.findtext('URL') print(url) print(prio) print() if url: try: urlretrieve(url, file_name + '.pack') except Exception as e: print('failed filmlist download', str(e)) try: with open(file_name, 'wb') as unpack_file_handle: unpack_file_handle.write( lzma.open(file_name + '.pack').read()) except Exception as e: print('failed filmlist unpack', str(e)) except Exception as e: print('failed filmlist server list download') loader_remember_data = {'provider': '', 'category': ''} ''' Bootstrap to read the filmlist: 1. read the list of actual filmlist URLs from https://res.mediathekview.de/akt.xml ''' #with open('/home/steffen//Desktop/workcopies/schnipsl/Filmliste-akt') as data: with open(file_name) as data: count = 0 for liste in JsonSlicer(data, ('X'), path_mode='map_keys'): count += 1 data_array = liste[1] # "Sender" 0, # "Thema" 1, # "Titel" 2, # "Datum" 3, # "Zeit" 4, # "Dauer" 5, # "Größe [MB]" 6, # "Beschreibung" 7, # "Url" 8, # "Website" 9, # "Url Untertitel" 10, # "Url RTMP" 11, # "Url Klein" 12, # "Url RTMP Klein" 13, # "Url HD" 14, # "Url RTMP HD" 15, # "DatumL" 16, # "Url History" 17, # "Geo" 18, # "neu" 19 provider = data_array[0] category = data_array[1] if provider: loader_remember_data['provider'] = provider else: provider = loader_remember_data['provider'] if category: loader_remember_data['category'] = category else: category = loader_remember_data['category'] if category == 'Livestream': source_type = defaults.MOVIE_TYPE_STREAM plugin_name = self.plugin_names[1] provider = provider.replace('Livestream', '').strip() #print("Livestream") else: plugin_name = self.plugin_names[0] source_type = defaults.MOVIE_TYPE_RECORD self.providers.add(provider) new_movie = Movie(source=plugin_name, source_type=source_type, provider=provider, category=category, title=data_array[2], timestamp=data_array[16], duration=self.time_string_to_secs( data_array[5]), description=data_array[7], url=data_array[8]) new_movie.add_stream('mp4', '', data_array[8]) if not plugin_name in self.movies: self.movies[plugin_name] = {} self.movies[plugin_name][new_movie.uri()] = new_movie print("filmlist loaded, {0} entries", count)
def movies_page(): if request.method == "POST": movie = Movie(request.form['title'].title(), "", "", "", "") score = request.form['score'] comments = request.form['comment'] if int(score) < 1 or int(score) > 10: flash("Your rating to the movie should be between 1 and 10.") return redirect(url_for('page.movies_page')) #checks if user is logged in if current_user.get_id() is not None: if (movie.search_movie_in_db() != -1): movieId = movie.search_movie_in_db() userMoviePair = WatchedList(current_user.username, movieId, score) post = Post(current_user.get_user_id(), movieId, comments) oldscore = userMoviePair.existsInWatchedList() if (oldscore != -1): oldscore = oldscore[0] if int(oldscore) == int(score): flash("You have already added " + movie.title + ".") return redirect(url_for('page.home_page')) else: userMoviePair.updateScoreOfWatchedMovie() oldScoreMoviesTable = int( movie.getscore_in_movie_db(movieId)[0]) totalVotes = int( movie.getvotes_in_movie_db(movieId)[0]) newscore = ((oldScoreMoviesTable * totalVotes) - int(oldscore) + int(score)) / (totalVotes) movie.update_votes_and_score(movieId, newscore, totalVotes) flash("You score to " + movie.title + " is updated as " + score + ".") return redirect(url_for('page.home_page')) else: userMoviePair.add_movie_user_pair() #score and vote need to be updated on movies table oldscore = int(movie.getscore_in_movie_db(movieId)[0]) totalVotes = int(movie.getvotes_in_movie_db(movieId)[0]) newscore = ((oldscore * totalVotes) + int(score)) / (totalVotes + 1) totalVotes = totalVotes + 1 movie.update_votes_and_score(movieId, newscore, totalVotes) post.add_post_to_db() flash( movie.title + " is added to your watched list and your post has been saved." ) return redirect(url_for('page.home_page')) else: movieToAdd = movie.verify_movie_from_api() if (movieToAdd == -1): flash("There is no such movie") return redirect(url_for('page.home_page')) else: movieToAdd = movie.verify_movie_from_api() movieToAdd.score = score movieToAdd.add_movie_to_db() flash( movieToAdd.title + " (" + movieToAdd.year + ") is added to your watched list and your post has been saved." ) movieId = movieToAdd.search_movie_in_db() userMoviePair = WatchedList(current_user.username, movieId, score) userMoviePair.add_movie_user_pair() post = Post(current_user.get_user_id(), movieId, comments) post.add_post_to_db() return redirect(url_for('page.home_page')) else: flash("Please log in to MovieShake") return redirect(url_for('page.login_page')) else: if current_user.get_id() is not None: return render_template('movies.html') else: flash("Please log in to MovieShake") return redirect(url_for('page.login_page'))
def load_filmlist(self, file_name): origin_dir = os.path.dirname(__file__) file_name = os.path.join(origin_dir, file_name) update_list = None print(os.path.abspath(file_name)) try: # does the file exist at all already? xmltv_updates_time_stamp = os.path.getmtime(file_name) except: xmltv_updates_time_stamp = 0 print("timestamp", xmltv_updates_time_stamp, time.time()) if xmltv_updates_time_stamp < time.time( ) - 60 * 60 * 48: # file is older as 48 hours print("Retrieve xmltv_updates list") try: urlretrieve('https://xmltv.xmltv.se/datalist.xml.gz', file_name) except Exception as e: print('failed xmltv_updates download', str(e)) try: with open(file_name, 'rb') as xmltv_updates_file_handle: update_list = parse(xmltv_updates_file_handle) except Exception as e: print('failed xmltv_updates read', str(e)) epg_data = self.config.read('epg', {}) collect_lastmodified = {} if update_list: for channel in update_list.iterfind('channel'): channel_id = channel.attrib['id'] self.allChannels.add(channel_id) if channel_id in self.favorite_channels: if not channel_id in collect_lastmodified: collect_lastmodified[channel_id] = {} for datafor in channel.iterfind('datafor'): day_text = datafor.text last_modified = datafor.attrib['lastmodified'] collect_lastmodified[channel_id][ day_text] = last_modified # first we delete old, outdated dates for channel_id in list(epg_data): if not channel_id in collect_lastmodified: del (epg_data[channel_id]) # delete the whole channel else: for day_text in list(epg_data[channel_id]): if not day_text in collect_lastmodified[channel_id]: del (epg_data[channel_id][day_text]) # check for updates: for channel_id in collect_lastmodified: print(channel_id) if not channel_id in epg_data: epg_data[channel_id] = {} for day_text in collect_lastmodified[channel_id]: try: if not day_text in epg_data[channel_id]: epg_details = self.load_from_xmltv( channel_id, day_text) epg_data[channel_id][day_text] = { 'lastmodified': collect_lastmodified[channel_id][day_text], 'epg_data': epg_details } print('store', channel_id, day_text) else: if epg_data[channel_id][day_text][ 'lastmodified'] < collect_lastmodified[ channel_id][day_text]: epg_details = self.load_from_xmltv( channel_id, day_text) epg_data[channel_id][day_text] = { 'lastmodified': collect_lastmodified[channel_id][day_text], 'epg_data': epg_details } print("update epg for ", channel_id, day_text) except Exception as e: print('exception on load_from_xmltv', channel_id, day_text, str(e)) self.config.write('epg', epg_data, False) # refill the internal lists self.providers = set() self.categories = set() plugin_name = self.plugin_names[0] if not plugin_name in self.movies: # this is an indicator that the epg was loaded from disk and not updated from xmltv.se, so we need to fill a few structures self.movies[plugin_name] = {} for provider, days in epg_data.items(): self.providers.add(provider) self.timeline[provider] = [] for movie_data in days.values(): for movie_info in movie_data['epg_data']: self.timeline[provider].append( type( '', (object, ), { 'timestamp': movie_info['timestamp'], 'movie_info': movie_info })()) self.movies[plugin_name][movie_info['uri']] = Movie( source=plugin_name, source_type=defaults.MOVIE_TYPE_STREAM, provider=provider, category=movie_info['category'], title=movie_info['title'], timestamp=movie_info['timestamp'], duration=movie_info['duration'], description=movie_info['description'], url=None) self.categories.add(movie_info['category']) for epg_list in self.timeline.values(): epg_list.sort(key=self.get_timestamp)
def list_page(): if request.method == "POST": flag = False if current_user.username is None: flash('Please log in.') return redirect(url_for('page.login_page')) else: list_name = request.form['name'] movie1 = request.form['moviename1'] movie2 = request.form['moviename2'] movie3 = request.form['moviename3'] movie4 = request.form['moviename4'] list_array = [ movie1.title(), movie2.title(), movie3.title(), movie4.title() ] smovie = Movie(list_array[0], "", "", "", "") movie = smovie.search_movie_in_db() newlist = MovieList(current_user.get_user_id(), movie, list_name) for movie in list_array: if movie == "": continue else: smovie = Movie(movie, "", "", "", "") movie = smovie.search_movie_in_db() if movie == -1: movieToAdd = smovie.verify_movie_from_api() if (movieToAdd == -1): flash("There is no such movie") return redirect(url_for('page.home_page')) else: movieToAdd.score = 7 movieToAdd.add_movie_to_db() movieid = movieToAdd.search_movie_in_db() newlist = MovieList(current_user.get_user_id(), movieid[0], list_name) newlist.add_movie() else: newlist = MovieList(current_user.get_user_id(), movie, list_name) if newlist.exists() == 1: flash('You have already added that movie.') return redirect(url_for('page.list_page')) else: newlist.add_movie() return redirect(url_for('page.home_page')) else: return render_template('list.html')
def read_data(movies, characters, females, males, unknowns): inMovies = open('%s/1_titles_clean.txt' % (CORNELL_SRCFOL), mode='r', encoding='ISO-8859-1') inChars = open('%s/3_characters_gendered_genderize.txt' % (CORNELL_SRCFOL), mode='r', encoding='ISO-8859-1') inLines = open('%s/1_lines_clean.txt' % (CORNELL_SRCFOL), mode='r', encoding='ISO-8859-1') # Stores movie metadata for line in inMovies: fields = line.replace('\n', '').rsplit('\t') id = int(fields[0][1:]) title = fields[1] year = int(fields[2]) rating = float(fields[3]) votes = int(fields[4]) genres = None if len(fields) < 6 else fields[5].rsplit(', ') movie = Movie(id, title, year, rating, votes, genres) movies.append(movie) # Stores character metadata for line in inChars: fields = line.replace('\n', '').rsplit('\t') id = int(fields[0][1:]) name = fields[1] movieID = int(fields[2][1:]) movie = movies[movieID] gender = fields[4] pos = int(fields[5]) character = Character(id, name, movie, gender, pos) movie.add_character(character) characters.append(character) # Adds character to Characters object corresponding to gender if (character.gender() == 'f'): females.append(character) elif (character.gender() == 'm'): males.append(character) else: unknowns.append(character) # Stores lines with corresponding character for line in inLines: fields = line.replace('\n', '').rsplit('\t') # Continue if no line is spoken if (len(fields) < 5): continue id = int(fields[0][1:]) charID = int(fields[1][1:]) movieID = int(fields[2][1:]) text = fields[4] characters[charID].add_line(text) inMovies.close() inChars.close() inLines.close()
class project_unit_test(unittest.TestCase): def setUp(self): database_interaction.actor_delete(self, 1) database_interaction.actor_delete(self, 880) database_interaction.actor_delete(self, 2219) database_interaction.actor_delete(self, 1327) database_interaction.movie_delete(self, 76341) database_interaction.movie_delete(self, 28) database_interaction.movie_delete(self, 238) database_interaction.movie_delete(self, 105) print(f'Se terminó setUp\n\n') ########################## API Actor Existente ############################################## mock_data = { 'id': '1', 'name': 'George Lucas', 'biography': 'Creador de Star Wars', 'birthday': '1944-05-14', 'deathday': 'None' } @patch('api_interaction.api_searchs.search_actor', return_value=mock_data) def test_bring_actor_from_api(self, search_actor): person = data_getter_from_api.get_actor(self, 1) set_1 = Actor(1, 'George Lucas', 'Creador de Star Wars', '1944-05-14', 'None') self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(person.death_date, set_1.death_date) ################################ API Actor no existente ###################################### mock_data = { 'id': '0', 'name': 'Not found', 'biography': 'No data', 'birthday': 'No data', 'deathday': 'No data' } @patch('api_interaction.api_searchs.search_actor', return_value=mock_data) def test_bring_actor_from_api_not_exist(self, search_actor): person = data_getter_from_api.get_actor(self, 0) set_1 = Actor(0, 'Not found', 'No data', 'No data', 'No data') self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(person.death_date, set_1.death_date) ############################## API Movie Existente ########################################### mock_data = { 'id': '1', 'original_title': 'Spider-Man', 'release_date': '2002', 'overview': 'Really cool movie' } @patch('api_interaction.api_searchs.search_movie_by_id', return_value=mock_data) def test_bring_movie_from_api(self, search_movie_by_id): set_1 = Movie(1, 'Spider-Man', '2002', 'Really cool movie') film = data_getter_from_api.get_movie(self, 1) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) ########################### API Movie No existente ############################################3 mock_data = { 'id': '0', 'original_title': 'no found', 'release_date': 'no data', 'overview': 'no data' } @patch('api_interaction.api_searchs.search_movie_by_id', return_value=mock_data) def test_bring_movie_from_api_not_exist(self, search_movie_by_id): set_1 = Movie(0, 'no found', 'no data', 'no data') film = data_getter_from_api.get_movie(self, 0) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) ################################## Mostrar todas las peliculas ############################################################## mock_data = { 'results': [{ 'id': 1, 'original_title': 'Spider-Man', 'release_date': '2002', 'overview': 'Really cool movie' }, { 'id': 2, 'original_title': 'Scarface', 'release_date': '1983', 'overview': 'Retro movie' }] } @patch('api_interaction.api_searchs.search_movie_by_title', return_value=mock_data) def test_bring_movies_list_api(self, search_movie_by_title): set_1 = Movie(1, 'Spider-Man', '2002', 'Really cool movie') set_2 = Movie(2, 'Scarface', '1983', 'Retro movie') sets = [] sets.append(set_1) sets.append(set_2) movie_list = data_getter_from_api.get_movie_by_title(self, 'Mokceado') for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview) ################################### Mostar todas los Actores ##########################################################3 mock_data = Actor(1, 'George Lucas', 'Creador de Star Wars', '1944-05-14', 'None') @patch('api_interaction.database_searchs.search_actor', return_value=mock_data) def test_bring_actor_from_DB(self, search_actor): person = data_getter_from_database.get_actor(self, 'Mock') set_1 = Actor(1, 'George Lucas', 'Creador de Star Wars', '1944-05-14', 'None') self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(person.death_date, set_1.death_date) ########################### Traer pelicula de BD ################################################## mock_data = Movie(1, 'Spider-Man', '2002', 'Really cool movie') @patch('api_interaction.database_searchs.search_movie_by_id', return_value=mock_data) def test_bring_movie_from_DB(self, search_movie_by_id): film = data_getter_from_database.get_movie_by_id(self, 'MOck') set_1 = Movie(1, 'Spider-Man', '2002', 'Really cool movie') self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) ########################### traer peliculas de BD ############################################################ mock_data = [ Movie(1, 'Spider-Man', '2002', 'Really cool movie'), Movie(2, 'Scarface', '1983', 'Retro movie') ] @patch('api_interaction.database_searchs.search_movie_by_title', return_value=mock_data) def test_bring_movies_list_from_DB(self, search_movie_by_title): movie_list = data_getter_from_database.get_movie_by_title( self, '_Mocks_') sets = [ Movie(1, 'Spider-Man', '2002', 'Really cool movie'), Movie(2, 'Scarface', '1983', 'Retro movie') ] for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview) #################### traer Actores de BD ######################################## mock_data = [ Actor(1, 'George Lucas', 'Creador de Star Wars', '1944-05-14', 'None'), Actor(2, 'Al Pacino', 'Finge ser Gangstre', '1940-04-25', 'None') ] @patch('api_interaction.database_searchs.get_all_actors', return_value=mock_data) def test_bring_all_actors_from_DB(self, get_all_actors): all_actors = data_getter_from_database.get_all_actors_from_db(self) sets = [ Actor(1, 'George Lucas', 'Creador de Star Wars', '1944-05-14', 'None'), Actor(2, 'Al Pacino', 'Finge ser Gangstre', '1940-04-25', 'None') ] for x in range(len(all_actors)): self.assertEqual(all_actors[x].actor_id, sets[x].actor_id) self.assertEqual(all_actors[x].name, sets[x].name) self.assertEqual(all_actors[x].biography, sets[x].biography) self.assertEqual(all_actors[x].birth_date, sets[x].birth_date) self.assertEqual(all_actors[x].death_date, sets[x].death_date) mock_data = [ Movie(1, 'Spider-Man', '2002', 'Really cool movie'), Movie(2, 'Scarface', '1983', 'Retro movie') ] @patch('api_interaction.database_searchs.get_all_movies', return_value=mock_data) def test_bring_movies_list_from_DB_(self, get_all_movies): movie_list = data_getter_from_database.get_all_movies_from_db(self) sets = [ Movie(1, 'Spider-Man', '2002', 'Really cool movie'), Movie(2, 'Scarface', '1983', 'Retro movie') ] for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview) ########################################################################################################################## ################################################ Test api_interaction #################################################### ########################################################################################################################## ################ API Actor existente##################################### def test_bring_actor_from_api_inte(self): person = data_getter_from_api.get_actor(self, 880) set_1 = Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(str(person.death_date), set_1.death_date) ############## API Actor no existente################################## def test_bring_actor_from_api_no_existente(self): person = data_getter_from_api.get_actor(self, 3123135414124124123) set_1 = Actor(3123135414124124123, 'None', 'None', 'None', 'None') self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(str(person.name), set_1.name) self.assertEqual(str(person.biography), set_1.biography) self.assertEqual(str(person.birth_date), set_1.birth_date) self.assertEqual(str(person.death_date), set_1.death_date) ############## API Movie Existente ################################### def test_bring_movie_from_api_inte(self): set_1 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) film = data_getter_from_api.get_movie(self, 76341) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) ############## API Movie no Existente ################################### def test_bring_movie_from_api_no_existente(self): set_1 = Movie(31241232351234324, 'None', 'None', 'None') film = data_getter_from_api.get_movie(self, 31241232351234324) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(str(film.title), set_1.title) self.assertEqual(str(film.date_of_release), set_1.date_of_release) self.assertEqual(str(film.overview), set_1.overview) ############################################################################################ ############################### unitarios ################################################### ############################################################################################# ##################### Traer de BD Actor ################################ def test_actor_from_BD(self): set_1 = Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') database_workclass.insert_actor(self, set_1) person = database_searchs.search_actor(self, 880) self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(str(person.death_date), set_1.death_date) database_workclass.delete_actor(self, set_1.actor_id) ############## BD Movie Existente por ID ################################### def test_bring_movie_from_BD_id(self): set_1 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.insert_movie(self, set_1) film = database_searchs.search_movie_by_id(self, 76341) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) database_workclass.delete_movie(self, set_1.movie_id) ############## API Movie Existente por Nombre ################################### # def test_bring_movie_from_BD_Title(self): # set_1 = Movie(557,'Spider-Man','2002-05-01','After being bitten by a genetically altered spider, nerdy high school student Peter Parker is endowed with amazing powers to become the Amazing superhero known as Spider-Man.') # film = database_searchs.search_movie_by_title(self,'Mad Max: Fury Road') # self.assertEqual(film.movie_id,set_1.movie_id) # self.assertEqual(film.title,set_1.title) # self.assertEqual(film.date_of_release,set_1.date_of_release) # self.assertEqual(film.overview,set_1.overview) ############ Get All Actors ################################################ def test_get_all_actors(self): set_1 = Actor( 1, 'George Lucas', "George Walton Lucas Jr. (born May 14, 1944) is an American filmmaker and entrepreneur. Lucas is known for creating the Star Wars and Indiana Jones franchises and founding Lucasfilm, LucasArts and Industrial Light & Magic. He served as chairman of Lucasfilm before selling it to The Walt Disney Company in 2012.\n\nAfter graduating from the University of Southern California in 1967, Lucas co-founded American Zoetrope with filmmaker Francis Ford Coppola. Lucas wrote and directed THX 1138 (1971), based on his earlier student short Electronic Labyrinth: THX 1138 4EB, which was a critical success but a financial failure. His next work as a writer-director was the film American Graffiti (1973), inspired by his youth in early 1960s Modesto, California, and produced through the newly founded Lucasfilm. The film was critically and commercially successful, and received five Academy Award nominations including Best Picture.\n\nLucas's next film, the epic space opera Star Wars (1977), had a troubled production but was a surprise hit, becoming the highest-grossing film at the time, winning six Academy Awards and sparking a cultural phenomenon. Lucas produced and co-wrote the sequels The Empire Strikes Back (1980) and Return of the Jedi (1983). With director Steven Spielberg, he created, produced and co-wrote the Indiana Jones films Raiders of the Lost Ark (1981), Temple of Doom (1984), The Last Crusade (1989) and Kingdom of the Crystal Skull (2008). He also produced and wrote a variety of films and television series through Lucasfilm between the 1970s and the 2010s.\n\nIn 1997, Lucas rereleased the Star Wars trilogy as part of a special edition featuring several alterations; home media versions with further changes were released in 2004 and 2011. He returned to directing with a Star Wars prequel trilogy comprising The Phantom Menace (1999), Attack of the Clones (2002), and Revenge of the Sith (2005). He last collaborated on the CGI-animated television series Star Wars: The Clone Wars (2008–2014, 2020), the war film Red Tails (2012), and the CGI film Strange Magic (2015).\n\nLucas is one of history's most financially successful filmmakers and has been nominated for four Academy Awards. His films are among the 100 highest-grossing movies at the North American box office, adjusted for ticket-price inflation. Lucas is considered a significant figure of the 20th-century New Hollywood movement.\n\nDescription above from the Wikipedia article George Lucas, licensed under CC-BY-SA, full list of contributors on Wikipedia.", '1944-05-14', 'None') set_2 = Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') database_workclass.insert_actor(self, set_1) database_workclass.insert_actor(self, set_2) sets = [ Actor( 1, 'George Lucas', "George Walton Lucas Jr. (born May 14, 1944) is an American filmmaker and entrepreneur. Lucas is known for creating the Star Wars and Indiana Jones franchises and founding Lucasfilm, LucasArts and Industrial Light & Magic. He served as chairman of Lucasfilm before selling it to The Walt Disney Company in 2012.\n\nAfter graduating from the University of Southern California in 1967, Lucas co-founded American Zoetrope with filmmaker Francis Ford Coppola. Lucas wrote and directed THX 1138 (1971), based on his earlier student short Electronic Labyrinth: THX 1138 4EB, which was a critical success but a financial failure. His next work as a writer-director was the film American Graffiti (1973), inspired by his youth in early 1960s Modesto, California, and produced through the newly founded Lucasfilm. The film was critically and commercially successful, and received five Academy Award nominations including Best Picture.\n\nLucas's next film, the epic space opera Star Wars (1977), had a troubled production but was a surprise hit, becoming the highest-grossing film at the time, winning six Academy Awards and sparking a cultural phenomenon. Lucas produced and co-wrote the sequels The Empire Strikes Back (1980) and Return of the Jedi (1983). With director Steven Spielberg, he created, produced and co-wrote the Indiana Jones films Raiders of the Lost Ark (1981), Temple of Doom (1984), The Last Crusade (1989) and Kingdom of the Crystal Skull (2008). He also produced and wrote a variety of films and television series through Lucasfilm between the 1970s and the 2010s.\n\nIn 1997, Lucas rereleased the Star Wars trilogy as part of a special edition featuring several alterations; home media versions with further changes were released in 2004 and 2011. He returned to directing with a Star Wars prequel trilogy comprising The Phantom Menace (1999), Attack of the Clones (2002), and Revenge of the Sith (2005). He last collaborated on the CGI-animated television series Star Wars: The Clone Wars (2008–2014, 2020), the war film Red Tails (2012), and the CGI film Strange Magic (2015).\n\nLucas is one of history's most financially successful filmmakers and has been nominated for four Academy Awards. His films are among the 100 highest-grossing movies at the North American box office, adjusted for ticket-price inflation. Lucas is considered a significant figure of the 20th-century New Hollywood movement.\n\nDescription above from the Wikipedia article George Lucas, licensed under CC-BY-SA, full list of contributors on Wikipedia.", '1944-05-14', 'None'), Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') ] all_actors = database_searchs.get_all_actors(self) for x in range(len(all_actors)): self.assertEqual(all_actors[x].actor_id, sets[x].actor_id) self.assertEqual(all_actors[x].name, sets[x].name) self.assertEqual(all_actors[x].biography, sets[x].biography) self.assertEqual(all_actors[x].birth_date, sets[x].birth_date) self.assertEqual(str(all_actors[x].death_date), sets[x].death_date) database_workclass.delete_actor(self, set_1.actor_id) database_workclass.delete_actor(self, set_2.actor_id) ################# Get all Movies ############################################ def test_get_all_movies(self): set_1 = Movie( 28, 'Apocalypse Now', '1979-08-15', 'At the height of the Vietnam war, Captain Benjamin Willard is sent on a dangerous mission that, officially, "does not exist, nor will it ever exist." His goal is to locate - and eliminate - a mysterious Green Beret Colonel named Walter Kurtz, who has been leading his personal army on illegal guerrilla missions into enemy territory.' ) set_2 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.insert_movie(self, set_1) database_workclass.insert_movie(self, set_2) movie_list = database_searchs.get_all_movies(self) sets = [ Movie( 28, 'Apocalypse Now', '1979-08-15', 'At the height of the Vietnam war, Captain Benjamin Willard is sent on a dangerous mission that, officially, "does not exist, nor will it ever exist." His goal is to locate - and eliminate - a mysterious Green Beret Colonel named Walter Kurtz, who has been leading his personal army on illegal guerrilla missions into enemy territory.' ), Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) ] for x in range(len(movie_list)): self.assertEqual(movie_list[x].movie_id, sets[x].movie_id) self.assertEqual(movie_list[x].title, sets[x].title) self.assertEqual(movie_list[x].date_of_release, sets[x].date_of_release) self.assertEqual(movie_list[x].overview, sets[x].overview) database_workclass.delete_movie(self, set_1.movie_id) database_workclass.delete_movie(self, set_2.movie_id) ################# insert Actor BD ################################################## def test_insert_actor(self): set_2 = Actor( 2219, 'Tobey Maguire', "Tobias Vincent Maguire is an American actor and film producer. He gained recognition for his role as Peter Parker / Spider-Man in Sam Raimi's Spider-Man trilogy. His other major films include Pleasantville, The Cider House Rules, Wonder Boys, Seabiscuit, The Good German, Brothers, and The Great Gatsby. Wikipedia", '1975-06-27', 'None') database_workclass.insert_actor(self, set_2) set_1 = Actor( 2219, 'Tobey Maguire', "Tobias Vincent Maguire is an American actor and film producer. He gained recognition for his role as Peter Parker / Spider-Man in Sam Raimi's Spider-Man trilogy. His other major films include Pleasantville, The Cider House Rules, Wonder Boys, Seabiscuit, The Good German, Brothers, and The Great Gatsby. Wikipedia", '1975-06-27', 'None') person = database_searchs.search_actor(self, 2219) self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(str(person.death_date), set_1.death_date) database_workclass.delete_actor(self, 2219) ################# Insert Movie BD ################################################# def test_insert_movie(self): set_2 = Movie( 238, 'The Godfather', '1972-03-14', 'Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.' ) database_workclass.insert_movie(self, set_2) set_1 = Movie( 238, 'The Godfather', '1972-03-14', 'Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.' ) film = database_searchs.search_movie_by_id(self, 238) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) database_workclass.delete_movie(self, 238) ################ Update Actor BD ################################################# def test_update_actor(self): set_2 = Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') database_workclass.insert_actor(self, set_2) set_3 = Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') database_workclass.update_actor(self, set_3) set_1 = Actor( 880, 'Ben Affleck', 'Ben Affleck (born Benjamin Géza Affleck-Boldt; August 15, 1972) is an American actor, film director, writer, and producer. He became known in the mid-1990s with his performance in the Kevin Smith films Mallrats (1995) and Chasing Amy (1997). Affleck is an Academy Award as well as a Golden Globe Award winner, along with Matt Damon, for their collaborative screenplay for the 1997 film Good Will Hunting. He established himself as a Hollywood leading man, having starred in several big budget films, such as Armageddon (1998), Pearl Harbor (2001), Changing Lanes (2002), The Sum of All Fears (2002), and Daredevil (2003). Affleck also portrays Bruce Wayne/Batman in the DC Extended Universe. He has portrayed the character in Batman vs Superman: Dawn of Justice (2016), Suicide Squad (2016), and Justice League (2017). He will reprise the role in 2021’s new version of Zack Snyder’s Justice League. Affleck has drawn critical acclaim for his work as a filmmaker, directing Gone Baby Gone (2007) and The Town (2010), and playing the lead role in the latter. He has worked with his younger brother, actor Casey Affleck, on several projects, including Good Will Hunting and Gone Baby Gone.\n\nAfter a high profile relationship with actress Gwyneth Paltrow in 1998, his relationship with actress/singer Jennifer Lopez attracted worldwide media attention in which Affleck and Lopez were dubbed "Bennifer". Following their breakup in 2004, he began dating Jennifer Garner. The two married in June 2005 and have two daughters, Violet Anne, born December 2005, and Seraphina Rose Elizabeth, born January 2009.\n\nAffleck has been actively involved in politics and charitable causes. He and Matt Damon also founded the production company LivePlanet.\n\nDescription above from the Wikipedia article Ben Affleck, licensed under CC-BY-SA, full list of contributors on Wikipedia.', '1972-08-15', 'None') person = database_searchs.search_actor(self, 880) self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(str(person.death_date), set_1.death_date) database_workclass.delete_actor(self, set_1.actor_id) ################# Update Movie BD ################################################# def test_update_movie(self): set_2 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.insert_movie(self, set_2) set_3 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) database_workclass.update_movie(self, set_3) set_1 = Movie( 76341, 'Mad Max: Fury Road', '2015-05-13', 'An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order.' ) film = database_searchs.search_movie_by_id(self, 76341) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview) database_workclass.delete_movie(self, set_3.movie_id) ############# Delete Actor BD ############################# def test_delete_actor(self): set_2 = Actor( 1327, 'Ian McKellen', "Sir Ian Murray McKellen, CH, CBE (born 25 May 1939) is an English actor. He is the recipient of six Laurence Olivier Awards, a Tony Award, a Golden Globe Award, a Screen Actors Guild Award, a BIF Award, two Saturn Awards, four Drama Desk Awards and two Critics' Choice Awards. He has also received two Academy Award nominations, eight BAFTA film and TV nominations and five Emmy Award nominations. McKellen's work spans genres ranging from Shakespearean and modern theatre to popular fantasy and science fiction. His notable film roles include Gandalf in The Lord of the Rings and The Hobbit trilogies and Magneto in the X-Men films.", '1939-05-25', 'None') database_workclass.insert_actor(self, set_2) database_workclass.delete_actor(self, 1327) set_1 = Actor('0', 'Not found', 'No data', 'No data', 'No data') person = database_searchs.search_actor(self, 1327) self.assertEqual(person.actor_id, set_1.actor_id) self.assertEqual(person.name, set_1.name) self.assertEqual(person.biography, set_1.biography) self.assertEqual(person.birth_date, set_1.birth_date) self.assertEqual(str(person.death_date), set_1.death_date) ############# Delete Movie BD ############################# def test_delete_movie(self): set_2 = Movie( 105, 'Back to the Future', '1985-07-03', "Eighties teenager Marty McFly is accidentally sent back in time to 1955, inadvertently disrupting his parents' first meeting and attracting his mother's romantic interest. Marty must repair the damage to history by rekindling his parents' romance and - with the help of his eccentric inventor friend Doc Brown - return to 1985." ) database_workclass.insert_movie(self, set_2) database_workclass.delete_movie(self, 105) set_1 = Movie('0', 'Not found', 'No data', 'No data') film = database_searchs.search_movie_by_id(self, 105) self.assertEqual(film.movie_id, set_1.movie_id) self.assertEqual(film.title, set_1.title) self.assertEqual(film.date_of_release, set_1.date_of_release) self.assertEqual(film.overview, set_1.overview)
#================================================================ if __name__ == "__main__": print("Biblioteka filmów\n") library = list() elements = 3 for _ in range(elements): title = Faker('pl_PL').catch_phrase() year = randint(1970, 2020) genre = Genre(randrange(23)) # Movie if randint(0, 1) == 0: obj = Movie(title=title, year=year, genre=genre) library.append(obj) # Series else: for season in range(randrange(10)): slist = add_season(title=title, year=year, genre=genre, season=season, episodes_in_season=randrange(20)) library.extend(slist) generate_views(library, elements) ttiles = top_titles(library, content_type=None) date = datetime.datetime.now().strftime('%x').replace('/', '.')
self.setWindowTitle("Edit Movie: {}".format(movieObject.name)) self.movieObject class MovieListView(QListWidget): def __init__(self, data, parent): super(MovieListView, self).__init__(parent) self.movieData = data #self.setText(data[]) class MovieItem(QListWidget): def __init__(self): super(MovieListView, self).__init__(parent) self.movieData = data if __name__ == "__main__": from PySide.QtGui import QDialog, QApplication import sys from classes import Movie testMovie = Movie.Movie( "/media/norbert/Datas/Filmek/Tomb.Raider.2018.BDRiP.x264.HuN-Gold/TombRaider.mkv" ) app = QApplication(sys.argv) win = EditMovieWindow(None) win.show() app.exec_()
def main(): active = True while active: # print("Por favor introduzca un nombre de usuario:") # user_name = input() print('\n') print( "Bienvenido a la wiki de actores y peliculas en terminal, las opciones de lo que puede hacer son:" ) print('Busqueda en la api:') print( "1 Consulte un actor\n2 Consulte una pelicula\n3 Consulte peliculas por titulo\n" ) print('Busqueda en BD local:') print( "4 Consulte un actor\n5 Consulte una pelicula\n6 Consulte peliculas por titulo" ) print('17 Mostrar todos los actores\n18 Mostrar todas la películas\n') print('Edicion de BD local:') print( "7 Insert manual de actor\n8 Insert manual de pelicula\n9 Editar la informacion de un actor\n10 Editar la informacion de una pelicula\n11 Eliminar un actor de la bd\n12 Eliminar una pelicula de la bd" ) print('Scrapeo:') print( '19 Insert masivo de actores con csv\n20 Insert masivo de peliculas con csv ' ) print('21 Salir del software\n') option = int(input()) if option == 1: print("Escriba el id del actor") _id = str(input()) d_g_a = data_getter_from_api() look_up_actor(_id, d_g_a) elif option == 2: print("Escriba el id de la pelicula") _id = str(input()) d_g_a = data_getter_from_api() look_up_movie(_id, d_g_a) elif option == 3: print("Escriba el titulo a buscar") title = str(input()) d_g_a = data_getter_from_api() look_up_movie_by_title(title, d_g_a) elif option == 4: print("Escriba el id del actor") _id = str(input()) d_g_d = data_getter_from_database() look_up_actor_local(_id, d_g_d) elif option == 5: print("Escriba el id de la pelicula") _id = str(input()) d_g_d = data_getter_from_database() look_up_movie_local(_id, d_g_d) elif option == 6: print('Escriba el titulo de la pelicula') title = str(input()) d_g_d = data_getter_from_database() look_up_movie_by_title_local(title, d_g_d) elif option == 7: print("Escriba el id del actor a insertar desde api") _id = str(input()) d_b_i = database_interaction() insert_actor_locally(_id, d_b_i) elif option == 8: print("Escriba el id de la pelicula a insertar desde api") _id = str(input()) d_b_i = database_interaction() insert_movie_locally(_id, d_b_i) elif option == 9: print("Escriba los datos del actor a editar") print('ID del actor:') _id = str(input()) print('Nuevo nombre del actor:') name = str(input()) print('Nueva Bio del actor:') bio = str(input()) print('Nueva fecha de nacimiento del actor:') bd = str(input()) print('Nueva fecha de defunción del actor:') dd = str(input()) d_b_i = database_interaction() update_actor_locally(Actor(_id, name, bio, bd, dd), d_b_i) elif option == 10: print("Escriba los datos de la pelicula a editar") print('ID de la película:') _id = str(input()) print('Nuevo título de la película:') title = str(input()) print('Nueva fecha de lanzamiento de la película:') release = str(input()) print('Nueva descripción de la película:') overv = str(input()) d_b_i = database_interaction() update_movie_locally(Movie(_id, title, release, overv), d_b_i) elif option == 11: print("Escriba el id del actor a borrar") _id = str(input()) d_b_i = database_interaction() delete_actor_locally(_id, d_b_i) elif option == 12: print("Escriba el id de la pelicula a borrar") _id = str(input()) d_b_i = database_interaction() delete_movie_locally(_id, d_b_i) elif option == 19: print( "Se cargarán actores desde la api con el csv que de a continuacion" ) file_path = str(input()) dbi = database_interaction() scrap_csv_file_actor(file_path, dbi) elif option == 20: print( "Se cargarán pelis desde la api con el csv que de a continuacion" ) file_path = str(input()) dbi = database_interaction() scrap_csv_file_movies(file_path, dbi) elif option == 21: active = False elif option == 17: d_g_d = data_getter_from_database() look_up_all_actors_local(d_g_d) elif option == 18: d_g_d = data_getter_from_database() look_up_all_movies_local(d_g_d) else: print("Opción no existente")