-
Notifications
You must be signed in to change notification settings - Fork 1
/
trackinfo
executable file
·96 lines (78 loc) · 2.57 KB
/
trackinfo
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
# -*- python -*-
#
# Copyright 2018 by Chris Osborn <[email protected]>
#
# This file is part of viddin.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at <http://www.gnu.org/licenses/> for
# more details.
import os
import sys
import argparse
import json
import xmltodict
import viddin
def build_argparser():
parser = argparse.ArgumentParser()
parser.add_argument("source", help="input file")
parser.add_argument("--title", type=int, help="title number to rip")
parser.add_argument("--lang", help="only use subtitles in specified language")
return parser
def trackWithUid(uid, tracks):
for track in tracks:
if 'uid' in track and uid == track['uid']:
return track
return None
def main():
args = build_argparser().parse_args()
if not os.path.exists(args.source):
print("Unable to locate " + args.source)
sys.exit(1)
source = viddin.Media(args.source, args.title)
tinfo = source.getTitleInfo()
for track in tinfo.tracks:
if 'DURATION' not in track:
track['DURATION'] = str(tinfo.length)
info = "%i:" % (track['rv_track_id'])
info += " Type=" + track['type']
info += " Forced="
if 'forced_track' in track and track['forced_track']:
info += "Yes"
else:
info += "No"
info += " Default="
if 'default_track' in track and track['default_track']:
info += "Yes"
else:
info += "No"
if 'uid' in track:
info += " UID=%i" % (track['uid'])
if 'language' in track:
lang = track['language']
if args.lang and lang != args.lang:
continue
info += " Language=%s" % (lang)
if 'DURATION' in track:
dur = viddin.decodeTimecode(track['DURATION'])
info += " Duration=%s" % (viddin.formatTimecode(dur))
if 'NUMBER_OF_FRAMES' in track:
info += " Frames=%s" % (track['NUMBER_OF_FRAMES'])
if 'NUMBER_OF_BYTES' in track:
info += " Bytes=%s" % (track['NUMBER_OF_BYTES'])
if 'codec' in track:
info += " Codec=%s" % (track['codec'])
if 'audio_channels' in track:
info += " Channels=%s" % (track['audio_channels'])
print(info)
return
if __name__ == '__main__':
exit(main() or 0)