-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmovie.py
74 lines (69 loc) · 1.91 KB
/
movie.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
import urllib
import json
import shutil
import os
import re
w=1
q=1
e=1
values=['.','[',']','(',')','m720p','480p','480','DVDSCR','BrRip','New Source','MP3','Mafiaking','1CD',
'mkv','mSD','2CD','BRRip','BRrip','720p','BluRay','YIFY','mp4','XviD','-','x264','ETRG','avi','StyLishSaLH'
,'DVD','dvd','DVDRip','RIP','rip','Rip','Back In Action']
def find(folder):
for x in os.listdir(folder):
#Edit to Regular Expression (Uncomment it if you want to use it.)
'''
if (re.search('^\s*[4-9]',x)):
continue
'''
#I found this easier to implement and read though. (I removed the dirty code)
if(x[0].isdigit() and x[0]>4):
continue
moviename=folder+'//'+x
for y in range(1500,2100):
if(str(y) in x):
x=x.replace(str(y)," ")
for z in values:
if(str(z) in x):
x=x.replace(str(z)," ")
if(" " in x):
x=x.replace(" "," ")
url='http://www.omdbapi.com/?t='+str(x)
response = urllib.urlopen(url).read()
jsonvalues = json.loads(response)
if jsonvalues["Response"]=="True":
imdbrating = jsonvalues['imdbRating']
print imdbrating+" "+x
destinationDir = 'F:\movies\\'+ imdbrating
if not os.path.exists(destinationDir):
os.makedirs(destinationDir)
shutil.move(moviename, destinationDir)
else:
a=0
f=1
e=0
g=0
for y in range(1,5):
x=x.replace(" ",": ",w)
if(a==1):
x=x.replace(":"," ",e)
url='http://www.omdbapi.com/?t='+str(x)
response = urllib.urlopen(url).read()
jsonvalues = json.loads(response)
if jsonvalues["Response"]=="True":
imdbrating = jsonvalues['imdbRating']
print imdbrating+" "+x
destinationDir = 'F:\movies\\'+ imdbrating
if not os.path.exists(destinationDir):
os.makedirs(destinationDir)
shutil.move(moviename, destinationDir)
break
else:
x=x.replace(": ",":",f)
if(g>0):
x=x.replace(" ",":",g)
a=1
g=g+1
e=e+1
find('F:\movies')