Last active
September 6, 2017 03:53
-
-
Save atreidesend/8439427b52d7581d764121b8ca58f7a0 to your computer and use it in GitHub Desktop.
IMDbPY NFO File Generator
This file contains 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 | |
import glob | |
import imdb | |
import webbrowser | |
movies_scratch = glob.glob('*/*.mkv') | |
ia = imdb.IMDb() | |
for movie_path in movies_scratch: | |
new_outpath = movie_path[0:-4]+'.nfo' | |
# if the file exists and is not empty, leave it alone | |
if (os.path.isfile(new_outpath) and os.path.getsize(new_outpath) > 0): | |
break | |
else: | |
output = open(new_outpath,'w') | |
output.truncate() | |
moviename = os.path.basename(new_outpath)[0:-4] | |
year = int(moviename[-5:-1]) | |
moviename_noyear = moviename[0:-7] | |
results = ia.search_movie(moviename_noyear) | |
if (len(results) > 0 ): | |
for res in results: | |
if (res['year'] == year): | |
print res | |
print res['year'] | |
result_link = "http://www.imdb.com/title/tt" + res.movieID + "/" | |
webbrowser.open(result_link,new=2) | |
break | |
else: | |
result_link = "" | |
else: | |
result_link = "" | |
output.write(result_link) | |
output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment