class Main(): # Create instances of movie object in Movie class DilWaleDulhaniyaLejayeinge = movie.Movie( "Dil Wale Dulhaniya Lejayeinge", "https://image.tmdb.org/t/p/original/pVGzV02qmHVoKx9ehBNy7m2u5fs.jpg", "http://www.youtube.com/watch?v=1U9SpwJ9TCs", "A block buster in 1990's") Lagaan = movie.Movie( "Lagaan", "http://media.movietalkies.com/posters/bollywood/movies/2001/lagaan/lagaan-2001-4b.jpg", "http://www.youtube.com/watch?v=FNX1beRgwJ8", "A must-watch for Amir Khan fans") TwoStates = movie.Movie( "Two States", "https://pbs.twimg.com/profile_images/438944211245617152/cDjvFT3A.jpeg", "http://www.youtube.com/watch?v=CGyAaR2aWcA", "The best depiction between North Indian culture and South Indian culture" ) ThreeIdiots = movie.Movie( "Three Idiots", "http://media1.santabanta.com/full1/Bollywood%20Movies/3%20Idiots/3-idiots-20h.jpg", "https://www.youtube.com/watch?v=xvszmNXdM4w", "A must watch for Amir Khan fans") # Create a list of movies instantiated above movies_list = [DilWaleDulhaniyaLejayeinge, Lagaan, TwoStates, ThreeIdiots] fresh_tomatoes.open_movies_page(movies_list)
def main(): movie1 = movie.Movie('Zootopia', 'Mar.4, 2016', 'Rotten Tomatoes: 8.1/10', 'Byron Howard and Rich Moore') movie2 = movie.Movie('Fantastic Beasts', 'Nov 18, 2016', 'Rotten Tomatoes: 6.8/10', 'David Yates') movie3 = movie.Movie('Now you see me', 'May 31, 2013', 'Rotten Tomatoes: 5.7/10', 'Louis Leterrier') print('Movie 1:', movie1) print('Movie 2:', movie2) print('Movie 3:', movie3)
def create_movie_object(imdb_id, youtube_trailer_id): omdb_data = get_omdb_data(imdb_id) # By default this is the returning value new_movie = None if omdb_data: # Was data returned from omdb ? # Avoid malformed JSON try: movies_json = json.loads(omdb_data) except ValueError, e: movies_json = json.loads( "{}") # On exception, create an empty JSON # Please Udacity's code reviewers: is this a correct approach # on breaking lines in IF's ? if "True" in movies_json["Response"] and \ "movie" in movies_json["Type"]: # Must be a movie new_movie = movie.Movie(title=movies_json["Title"], year=movies_json["Year"], rating=movies_json["Rated"], runtime=movies_json["Runtime"], genre=movies_json["Genre"], director=movies_json["Director"], actors=movies_json["Actors"], plot=movies_json["Plot"], poster_image_url=movies_json["Poster"], imdb_rating=movies_json["imdbRating"], trailer_youtube_id=youtube_trailer_id)
def build_movie(imdb_id, youtube_url): imdb_content = urllib.urlopen("http://www.imdb.com/title/" + imdb_id).read() parser = imdb_parser.IMDBParser() parser.feed(imdb_content) return movie.Movie(parser.title, parser.storyline, parser.poster_url, youtube_url)
def test(list): movies_list = [] for i in list: m = movie.Movie('path', 'x') m.imdb_link = i movies_list.append(m) return movies_list
def get_movie_list(): ''' Creates a list movies with trivia and youtube trailer url. ''' # Get api keys and movie names from files. keys = get_data_list_from_file(keys_file) youtube_key = keys[0] omdb_key = keys[1] movie_names = get_data_list_from_file(movie_names_file) # Compiles a list of movie objects using Youtube and OMDB APIs movie_list = [] for movie_name in movie_names: # Get data from Youtube and OMDB using APIs search_phrase = movie_name.replace(" ", "+") omdb_url = "http://www.omdbapi.com/?t=" + \ search_phrase + \ "&plot=full&apikey=" + omdb_key youtube_url = "https://www.googleapis.com/youtube" \ "/v3/search?part=id&q=" + search_phrase + "+trailer" \ "&type=video&key=" + youtube_key omdb_data = get_data_from_api(omdb_url) youtube_data = get_data_from_api(youtube_url) youtube_video_id = str(youtube_data['items'][0]['id']['videoId']) # Create a movie object and add to movie_list movie_data = movie.Movie(movie_name, omdb_data, youtube_video_id) movie_list.append(movie_data) return movie_list
def main(args): filename = args.input m = movie.Movie( filename, every_n_video_frames=args.every_n_video_frames, audio_bitrate=args.audio_bitrate, audio_normalization=args.audio_normalization, max_bytes_out=1024. * 1024 * args.max_output_mb, video_mode=video_mode.VideoMode[args.video_mode], palette=palette.Palette[args.palette], ) print("Palette %s" % args.palette) print("Input frame rate = %f" % m.frame_grabber.input_frame_rate) if args.output: out_filename = args.output else: # Replace suffix with .a2m out_filename = ".".join(filename.split(".")[:-1] + ["a2m"]) with open(out_filename, "wb") as out: for bytes_out, b in enumerate(m.emit_stream(m.encode())): out.write(bytearray([b]))
def CheckDiskMovie(DiskPath): ''' 对DiskPath下的每一个DirName加入对象实体到MyMovies[]并调用movie.CheckMovie()进行检查和处理,包括 1)检查目录名称(CheckDirName) 2)检查内容(CheckDirCont) 3)进行目录重命名(RenameDirName) ''' global g_MyMovies global g_Count if not os.path.isdir(DiskPath) : print(DiskPath+"is not a dir"); return -1 for file in os.listdir(DiskPath): fullpathfile = os.path.join(DiskPath,file) if os.path.isdir(fullpathfile): #一些特殊文件夹忽略 if file == 'lost+found' or \ file[0:6] == '.Trash' or \ file[0:8] == '$RECYCLE' or\ file == '0000': print ("ignore some dir:"+file) continue g_MyMovies.append(movie.Movie(DiskPath,file)) if g_MyMovies[g_Count].CheckMovie() == 0: print ("CheckMovie error:"+g_MyMovies[g_Count].DirName) else: print ("CheckMovie correct:"+g_MyMovies[g_Count].DirName) g_Count += 1 return 1
def exampleMovie(): testMovie = movie.Movie() testMovie.capture_count = 100 testMovie.frame_count = 0 testMovie.cur_frame = 1 testMovie.preview_count = 20 testMovie.data_file = "testData.p" return testMovie
def post(self): movies_str = self.request.params.get('movies') logging.info(movies_str) movies = json.loads(movies_str) ndb.put_multi_async([movie.Movie(**amovie) for amovie in movies]) self.response.headers.add_header("Access-Control-Allow-Origin", "*") self.response.headers['Content-Type'] = '*.*' self.response.write('Hello')
def get_movie_summary(self, url_or_id): if 'http' in url_or_id.lower(): soup = utils.get_soup(url_or_id) if soup is not None: return movie.Movie(soup) else: print "Not able to parse url: " + url_or_id pass elif url_or_id in self.movie_urls.keys(): url = self.BOMURL + "/?page=main&id=" + url_or_id + ".htm" soup = utils.get_soup(url) if soup is not None: return movie.Movie(soup) else: print "Not able to parse url: " + url pass else: print "Invalid movie name or URL ", url_or_id
def createMovie(title,startYear, runtime, genre1, genre2, genre3, numVotes): genres = "" + genre1 if genre2 != "": genres = genres + "," + genre2 if genre3 != "": genres = genres + "," + genre3 array = [0,title,startYear, runtime,genres,0,numVotes] newMovie = movie.Movie(array) return newMovie
def get_offline_list(): # Movie 1 delhi_belly = movie.Movie("Delhi Belly", "A man faces life", 'http://contact25.com/uploads/7_16764.jpg', "https://www.youtube.com/watch?v=iSVhPXvFDw8") # Movie 2 avengers = movie.Movie( "Avengers : Age of ultron", "The avengers fight a powerful AI who want's to finish humanity", 'https://static.comicvine.com/uploads/scale_small/11/113509/4413258-ultron.jpg', "https://www.youtube.com/watch?v=rD8lWtcgeyg") # Movie 3 war_for_the_planet = movie.Movie( "War for the Planet of the Apes", "Caesar (Andy Serkis) and his apes are forced into a deadly conflict with an army of humans led by a ruthless colonel (Woody Harrelson). " + "After the apes suffer unimaginable losses, Caesar wrestles with his darker instincts and begins his own mythic quest to avenge his kind." + "As the journey finally brings them face to face, Caesar and the colonel are pitted against each other in an epic battle that will determine " + "the fate of both of their species and the future of the planet.", 'http://cdn.collider.com/wp-content/uploads/2016/12/war-for-the-planet-of-the-apes-poster.jpg', "https://www.youtube.com/watch?v=qxjPjPzQ1iU") # Movie 4 the_man_who_knew_infinity = movie.Movie( "The man who knew infinity", "The story of the life and academic career of the pioneer Indian mathematician, Srinivasa Ramanujan, and his friendship with his mentor, Professor G.H. Hardy.", 'http://www.newdvdreleasedates.com/images/posters/large/the-man-who-knew-infinity-2015-04.jpg', "https://www.youtube.com/watch?v=oXGm9Vlfx4w") # Movie 5 wonder_woman = movie.Movie( "Wonder Woman", "Before she was Wonder Woman (Gal Gadot), she was Diana, princess of the Amazons, trained to be an unconquerable warrior. " + "Raised on a sheltered island paradise, Diana meets an American pilot (Chris Pine) who tells her about the massive conflict that's raging in the outside world. " + "Convinced that she can stop the threat, Diana leaves her home for the first time. Fighting alongside men in a war to end all wars, " + "she finally discovers her full powers and true destiny.", 'http://vignette3.wikia.nocookie.net/dccu/images/8/8e/Wonder_Woman_first_look_promo.jpg/revision/latest?cb=20160708135809', "https://www.youtube.com/watch?v=oXGm9Vlfx4w") return [ delhi_belly, avengers, war_for_the_planet, the_man_who_knew_infinity, wonder_woman ]
def parse(self, myfile, resources): self.movie = movie.Movie() self.movie.mac = self.mac self.movie.resources = resources self.myfile = myfile if 'VER ' in resources: self.parseVersion(resources['VER '][0]) if 'VER.' in resources: self.parseVersion(resources['VER.'][0]) if 'MCNM' in resources: # only present (and mandatory) on Windows self.parseMacName(resources['MCNM'][0]) assert 'VWCF' in resources self.parseMovieConfig(resources['VWCF'][0]) if myfile.version < 0xf000: assert 'VWCR' in resources self.parseMovieCastRecord(resources['VWCR'][0]) if 'VWCI' in resources: for i in resources['VWCI']: self.parseCastInfo(i) if 'CASt' in resources: for i in resources['CASt']: self.parseCastData(i) if 'VWSC' in resources: self.parseScore(self.getResourceById('VWSC', 1024)) if 'VWTC' in resources: pass # FIXME if 'VWLB' in resources: self.parseLabels(self.getResourceById('VWLB', 1024)) if 'VWAC' in resources: self.parseActions(self.getResourceById('VWAC', 1024)) if 'VWFI' in resources: self.parseFileInfo(self.getResourceById('VWFI', 1024)) else: self.movie.script = "" self.movie.changedBy = "" self.movie.createdBy = "" self.movie.flags = 0 self.movie.whenLoadCast = -1 if 'VWFM' in resources: self.parseFontMap(self.getResourceById('VWFM', 1024)) if 'VWTL' in resources: pass # FIXME if 'STXT' in resources: for i in resources['STXT']: self.parseText(i) # FIXME: stupid hack for dibs,bitmaps self.movie.dibs = {} if 'DIB ' in resources: for i in resources['DIB ']: self.movie.dibs[i.rid] = i self.movie.bitmaps = {} if 'BITD' in resources: for i in resources['BITD']: self.movie.bitmaps[i.rid] = i return self.movie
def get_movie_model(api_url): """ Make movie model from url """ res = requests.get(api_url).json() title = res['title'].encode('ascii', 'ignore') storyline = res['overview'].encode('ascii', 'ignore') yt_code = res['videos']['results'][0]['key'].encode('ascii', 'ignore') poster = 'https://image.tmdb.org/t/p/w500/' + res['poster_path'].encode( 'ascii', 'ignore') return movie.Movie(title, storyline, yt_code, poster)
def run(): """ Reads data from json file and creates html file.""" with open('data/movies.json') as data_file: data = json.load(data_file) movies = [] for d in data: movies.append(movie.Movie(d['title'], d['image'], d['url'])) fresh_tomatoes.open_movies_page(movies)
def get_movie_summary(self, alias): self.alias = alias url = self.BOMURL + "/?page=main&id=" + self.alias + ".htm" soup = utils.get_soup(url) if soup is not None: return movie.Movie(soup) else: print "Not able to parse url: " + url pass
def add(self, movie_object): if isinstance(movie_object, list): last_id = max(self.movies).id + 1 for _movie in movie_object: _movie.id = last_id self.movies.append( movie.Movie(_movie.id, _movie.title, _movie.year, _movie.actors, _movie.director)) last_id += 1 else: movie_object.id = max(self.movies).id + 1 self.movies.append( movie.Movie(movie_object.id, movie_object.title, movie_object.year, movie_object.actors, movie_object.director)) with open('movies.json', 'w') as f: json.dump(self.movies, f, cls=movie.MovieEncoder) return movie_object
def parse_movie_file(filename): movie_array = [] with open(filename) as fo: for idx, line in enumerate(fo): if idx: #ignore first line line_array = line.split("\t") title, summary, poster, trailer = line_array[0], line_array[1], line_array[2], line_array[3] current_movie = movie.Movie(title, summary, poster, trailer) print title, summary, poster, trailer movie_array.append(current_movie) random.shuffle(movie_array) return movie_array
def process_response(response): # Process response for a list of movies for item in response["items"]: movie_id = str(item["id"]) img = "https://image.tmdb.org/t/p/w185_and_h278_bestv2"\ + item["poster_path"] # Call to the api for each movie youtube_key = get_trailer(movie_id) youtube_url = "https://www.youtube.com/watch?v=" + youtube_key # Initialize new intance movie m = movie.Movie(item["original_title"], img, youtube_url) movies.append(m)
def main(): '''Function: Creating six movie objects and passing instance attributes to them. Args: None Returns: None''' matrix = movie.Movie('Matrix', 'The world is a simulation', 'https://goo.gl/8wvvf8', 'https://goo.gl/f6Qeha') star_wars = movie.Movie('Star Wars', 'The force awakens', 'https://goo.gl/zJ1Ve4', 'https://goo.gl/YG249N') toy_story = movie.Movie('Toy Story', 'A story of a boy and his toys that come to life', 'https://goo.gl/7RZSog', 'https://goo.gl/q92pYV') avatar = movie.Movie('Avatar', 'A marine on an alien planet', 'https://goo.gl/AxH37q', 'https://goo.gl/UcXQgR') deadpool = movie.Movie('Deadpool', 'Wait till you get a load of me', 'http://bit.ly/2eorTC7', 'https://goo.gl/EVY33t') ratatouille = movie.Movie('Ratatouille', 'A rat is a chef in Paris', 'https://goo.gl/bJJgTv', 'https://goo.gl/xaSxz3') movies = [matrix, star_wars, toy_story, avatar, deadpool, ratatouille] open_trailer.open_movies_page(movies)
def find_movie(self, id_): self.c.execute('SELECT* FROM movies WHERE id=?', (id_)) row = self.c.fetchone() id_ = row[0] movie_path = row[2] movie_name = row[1] imdb_link = row[3] cover = row[4] summary = row[5] imdb_rating = row[6] anaelle_rating = row[7] seen = row[8] return movie.Movie(id_, movie_path, movie_name, imdb_link, cover, summary, imdb_rating, anaelle_rating, seen)
def run(self, frames=None, dolphin_process=None): try: self.pads = self.get_pads() except KeyboardInterrupt: print("Pipes not initialized!") return pick_chars = [] tapA = [ (0, movie.pushButton(Button.A)), (0, movie.releaseButton(Button.A)), ] enter_stage_select = [(28, movie.pushButton(Button.START)), (1, movie.releaseButton(Button.START)), (10, movie.neutral)] for pid, pad in zip(self.pids, self.pads): actions = [] cpu = self.cpus[pid] if cpu: actions.append(MoveTo([0, 20], pid, pad, True)) actions.append(movie.Movie(tapA, pad)) actions.append(movie.Movie(tapA, pad)) actions.append(MoveTo([0, -14], pid, pad, True)) actions.append(movie.Movie(tapA, pad)) actions.append(MoveTo([cpu * 1.1, 0], pid, pad, True)) actions.append(movie.Movie(tapA, pad)) #actions.append(Wait(10000)) actions.append(MoveTo(characters[self.characters[pid]], pid, pad)) actions.append(movie.Movie(tapA, pad)) pick_chars.append(Sequential(*actions)) pick_chars = Parallel(*pick_chars) enter_settings = Sequential( MoveTo(settings, self.pids[0], self.pads[0]), movie.Movie(tapA, self.pads[0])) # sets the game mode and picks the stage # start_game = movie.Movie(movie.endless_netplay + movie.stages[self.stage], self.pads[0]) start_game = movie.Movie(enter_stage_select + movie.stages[self.stage], self.pads[0]) # self.navigate_menus = Sequential(pick_chars, enter_settings, start_game) self.navigate_menus = Sequential(pick_chars, start_game)
def example(): import os import boundingbox # Use my system's version of fmpeg instead of the one bundled with imageio-ffmpeg, # because my system's is more up to date os.environ['IMAGEIO_FFMPEG_EXE'] = 'ffmpeg' # The name of the recording to read name = '382321879' # Customize some bounding boxes x0 = 740 y0 = 60 bb1 = boundingbox.BoundingBox(-356, -270 + y0, 604, 270 + y0) bb2 = boundingbox.BoundingBox(-1248 + x0, -540 + y0, 672 + x0, 540 + y0) # Specify explicit time intervals t0 = 60 t1 = 456800 t2 = 478801 # Start the movie! By default use 'mandelbrot' for output files. m = movie.Movie(recording_name=name, filename='mandelbrot') m.start_movie(fps=60) scene = m.new_scene() scene.set_bb(bb1) scene.set_target_resolution(1920, 1080) # 120 seconds, 2 second pause at end, 1 second fade in, 0.5 second fade out scene.set_time_seconds(120, 2, 1, 0.5) scene.set_movie_real_time(t0, t1) scene.render_scene( False) # False means not to save a screenshot of the ending scene = m.new_scene() scene.set_bb(bb2) scene.set_target_resolution(1920, 1080) # 55 seconds, 5 second pause at end, 0.5 second fade in, 2 second fade out scene.set_time_seconds(55, 5, 0.5, 2) scene.set_movie_real_time(t1, t2) scene.render_scene() m.end_movie() # Add music. Requires ffmpeg to be installed on your system. m.add_music(movie.factorio_music_path + 'expansion.ogg')
def cutscene(oldslide=None, newslide=None, delay=0, onStart=fade, onStop=fade, allowExit=True, moviefile=None, soundfile=None, movie=None, **param): """Transitions from oldslide, plays a movie, and transitions back to newslide. @type oldslide: Panel @param oldslide: The Panel to exit. @type newslide: Panel @param newslide: The Panel to enter. @param delay: The time it should take to perform onStart and onStop individually, in seconds. @param onStart: The transition function used to transition from oldslide to the movie @param onStop: The transition function used to transition from the movie to newslide @param allowExit: Whether the user can skip the movie by hitting ESC. @param moviefile: The name of the movie file to play. Pygame currently only supports the MPEG-1 video codec. @param soundfile: The name of the sound file to play along with the movie. Any sound from the movie will be replaced with this sound. Use this if you are having trouble getting movie sound to play in Pygame. @type movie: Movie @param movie: An instance of the Movie class to play. If specified, any file you specify with the moviefile parameter will be ignored. @param **param: Additional arguments used in beginTransition() and endTransition() """ if not movie: movie = movie.Movie(id=None, moviefile=moviefile, soundfile=soundfile) stopped = False onStart(oldslide, movie, delay) clock = pygame.time.Clock() while not (movie.played or stopped): clock.tick(150) pyzzle.framerate = clock.get_fps() draw() for event in pygame.event.get(): if event.type == QUIT: sys.exit() if event.type == KEYDOWN: if event.key == K_ESCAPE and allowExit: stopped = True onStop(movie, newslide, delay)
def run(): length = 120 if len(sys.argv) >= 2: length = float(sys.argv[1]) fps = 30 if len(sys.argv) >= 3: fps = float(sys.argv[2]) m = movie.Movie() m.start_movie(fps=fps) scene = m.new_scene() scene.set_time_seconds(length) scene.set_movie_real_time() scene.render_scene() m.end_movie()
def clean_movienames(movienames, path): newmoviename = "" movies_list = [] count = 0 for moviename in movienames: newmoviename = moviename[:-4].replace(".", " ").lower() try: newmoviename = re.sub('(.*', '') except: None try: newmoviename = re.sub('french.*', '', newmoviename) except: None try: newmoviename = re.sub('dvdrip.*', '', newmoviename) except: None try: newmoviename = re.sub('1080p.*', '', newmoviename) except: None try: newmoviename = re.sub('vostfr.*', '', newmoviename) except: None try: newmoviename = re.sub('\[.*]', '', newmoviename) except: None try: newmoviename = re.sub('brrip.*', '', newmoviename) except: None try: newmoviename = re.sub('xvid.*', '', newmoviename) except: None m = movie.Movie(count, path + moviename, newmoviename) movies_list.append(m) count = count + 1 return movies_list
def make_action(self, reset_match): # menu = Menu(self.state.menu) # print(menu) if self.state.menu == Menu.Game.value: if reset_match: self.spam([Button.START, Button.A, Button.L, Button.R]) return None, RESETTING_MATCH_STATE return self.state, None elif self.state.menu in [ menu.value for menu in [Menu.Characters, Menu.Stages] ]: self.navigate_menus.move(self.state) if self.navigate_menus.done(): for pid, pad in zip(self.pids, self.pads): if self.characters[pid] == 'sheik': pad.press_button(Button.A) return None, MENU_SELECTION_STATE elif self.state.menu == Menu.PostGame.value: self.spam([Button.START], pad_indexes=[0, 1]) stage_select = [(28, movie.pushButton(Button.START)), (1, movie.releaseButton(Button.START)), (10, movie.neutral), (0, movie.tiltStick(Stick.MAIN, 1, 0.8)), (5, movie.tiltStick(Stick.MAIN, 0.5, 0.5)), (20, movie.pushButton(Button.START)), (1, movie.releaseButton(Button.START)), (0, movie.tiltStick(Stick.MAIN, 1, 0.8)), (5, movie.tiltStick(Stick.MAIN, 0.5, 0.5)), (20, movie.pushButton(Button.START)), (1, movie.releaseButton(Button.START))] self.navigate_menus = Sequential( movie.Movie(stage_select, self.pads[0])) return None, POSTGAME_STATE else: print("Weird menu state", self.state.menu) return None, POSTGAME_STATE
def filmData(movies): #variables to enter into the Movie class title = "" price = 0.0 genre = "" ans = 0 #Take variable input from the user title = input("Enter the title of the movie: ") price = float(input("Enter the rental cost of the movie: ")) ans = int( input("Is this a 1. new release, 2. children's film, or 3. other? ")) #turn input into genre if (ans == 1): genre = "New Release" elif (ans == 2): genre = "Children's" elif (ans == 3): genre = "General" #Running the variables through the Movie class to create a film object film = movie.Movie(title, price, genre) #Puts the film object into the movies list movies.append(film) #Tells user what is happening print("The movie has been entered into the database") with open("movieD_base.csv", 'r') as csv_file: csv_reader = csv.reader(csv_file) with open("movieD_base.csv", 'w') as new_file: wr = csv.writer(new_file, delimiter=',') fieldnames = ['TITLE', 'PRICE', 'GENRE'] csv_writer = csv.DictWriter(new_file, fieldnames=fieldnames, delimiter=',') csv_writer.writeheader() for line in csv_reader: csv_writer.writerow(line) for film in movies: wr.writerow(film.convertToMovieList())
def import_db(self): self.c.execute('SELECT* FROM movies') movies_list = [] while True: row = self.c.fetchone() if row == None: break id_ = row[0] movie_path = row[2] movie_name = row[1] imdb_link = row[3] cover = row[4] summary = row[5] imdb_rating = row[6] anaelle_rating = row[7] seen = row[8] m = movie.Movie(id_, movie_path, movie_name, imdb_link, cover, summary, imdb_rating, anaelle_rating, seen) movies_list.append(m) return movies_list