What's a better way to do this?
I need to sift through this file and store the following values
Cpl
File name
Content kind
Package type
Encryption status
Container
File size
Duration
Timed text/png
Number of audio channels
2d/3d
Fps
1) I'm not sure if I should just store these as lists?
2) Should I use dictionaries ?
Here's one sample file. Click Here
And here's how I was attempting to sort through the file, with not as much luck as I would like.
import glob
import os
import sys
print(os.getcwd())
dir=raw_input(["Please enter directory location of dcp_inspect output"])
print (dir)
os.chdir(dir)
print(os.getcwd())
cpl = []
content = []
errors = []
contentkind = []
package = []
summary = []
mainsound = []
mainpicture = []
encryption = []
filesize = []
duration = []
#Content kind
#Package type
#Encryption status
#Container
#File size
#Duration
#Timed text/png
#Number of audio channels
#2d/3d
for file in glob.glob("*"):
try:
print (file,'\t Was Successfully Opened')
#file = DcpParse()
newfile = file
print('Scanning...', newfile)
data = open(newfile)
for each_line in data:
if 'CPL Id:' in each_line:
cpl=(each_line.split())
elif 'ContentTitleText:' in each_line:
content=(each_line.split())
elif 'Errors' in each_line:
errors=(each_line.split())
elif 'ContentKind' in each_line:
contentkind=(each_line.split())
elif 'Composition summary' in each_line:
if 'fps' in each_line:
summmary=(each_line[0])
print('found comp sum',summary)
elif 'MainSound:' in each_line:
summmary=(each_line)
print('CPL=',cpl[2])
content.index('ContentTitleText:')
content.pop(0)
print('File Name on DCP',content)
print('Content Kind =',contentkind[1])
errors.pop(0)
print('There are',errors[0],'Errors and',errors[2],'hints for', content)
print('content summary',summary)
if errors[0] != '0':
print('could be issues')
else:
print('This DCP appears to be OK')
#print(summary)
data.close()
except:
pass