Created
August 4, 2013 16:48
-
-
Save abhididdigi/6150954 to your computer and use it in GitHub Desktop.
This is the entry point of the entire Movie scraping movies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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