-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdeleteSmaller.py
35 lines (33 loc) · 1 KB
/
deleteSmaller.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
from server import Server
server = Server("127.0.0.1", 32400)
tobedeleted = []
dryRun = False
import os
for show in server.library.shows[0].getContent('all'):
oldres = 0
oldpath = ''
for episode in show.getAllEpisodes():
for med in episode.media:
try:
newres = int(med.videoResolution)
except:
continue
newpath = med.part.file
if oldpath == '':
oldres = newres
oldpath = newpath
continue
if oldres < newres:
tobedeleted.append(oldpath)
oldres = newres
oldpath = newpath
else:
tobedeleted.append(newpath)
if dryRun:
print tobedeleted
else:
for delete in tobedeleted:
try:
os.remove(delete)
except Exception:
print "Could not delete %s" % delete