-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverifyTitles.py
More file actions
executable file
·54 lines (49 loc) · 1.59 KB
/
verifyTitles.py
File metadata and controls
executable file
·54 lines (49 loc) · 1.59 KB
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
#!/usr/bin/python
import os
import sys
from MediaClass import Media
import logging
#import re
#Default directory of movies
MOVIE_DIRECTORY = '/mnt2/Media/Movies'
'''
INPUT: Directory containing names and directories of the Movies
OUTPUT: a list of MediaClass.Media objects holding the absolute path to the file
and the name of the file with no extension
'''
def getRawNames(directory):
rawMedia = []
try:
files = os.listdir(directory)
except OSError:
sys.stderr.write('Invalid target directory: '+directory+'\n')
sys.stderr.write('Either doesn\'t exist or cannot access \n')
sys.stderr.write('Quitting...\n')
sys.exit(0)
for thisPath in files:
thisObject = Media()
thisObject.addPath(directory+"/"+thisPath)
rawMedia.append(thisObject)
return rawMedia
'''
INPUT: Media Object with a defined rawName
OUTPUT: logging module records issues with rawName
option to change rawName and path through commandLine
'''
def checkRawNameFormat(thisMedia):
rawName = thisMedia.getRawName()
#rawName should contain movie year between parentheses
leftPar = rawName.rfind('(')
rightPar = rawName.rfind(')')
if (leftPar > 0) and (rightPar > 0):
title = rawName[:leftPar].strip()
year = rawName[leftPar+1:rightPar]
#log if no parentheses
elif (leftPar > 0) or (rightPar > 0):
logging.warning("Movie %s does not have a year value",rawName)
else:
year = None
title = rawName
print title+'|'+year
if __name__ == '__main__':
rawTitles = getRawNames(MOVIE_DIRECTORY)