Skip to content

Instantly share code, notes, and snippets.

@abhididdigi
Created August 4, 2013 16:48
Show Gist options
  • Save abhididdigi/6150954 to your computer and use it in GitHub Desktop.
Save abhididdigi/6150954 to your computer and use it in GitHub Desktop.
This is the entry point of the entire Movie scraping movies.
import os
from ProcessMovieName import ProcessMovieName
from stack import custom_stack
from IMDBCall import IMDBCall
import json
#for making calls to IMDB
imdbcall = IMDBCall();
#Custom stack implementation for easiness.
stack = custom_stack();
#prune movies and make their names meaningful.
ProcessMovie = ProcessMovieName();
#Get the root directory of the movies.
root_dir = 'N:\Movies\Movies';
#Get all the filenames.
filesAndDir = [x[2] for x in os.walk(root_dir)]
# iterate all files, and then get only video files.
for i in filesAndDir :
[stack.push(fileName) for fileName in i if '.avi' in fileName or '.mkv' in fileName or '.mp4' in fileName]
output = [];
[output.append(imdbcall.getResults(ProcessMovie.process(name))) for name in stack.S]
#Convert the output to Valid JSON.
json.dumps(output);
#write it to a file called Output.json
text_file = open("Output.json", "w")
text_file.write("%s"%output)
text_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment