forked from FozzTexx/viddin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubinfo
executable file
·86 lines (71 loc) · 2.21 KB
/
subinfo
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
#!/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.
# FIXME - make this a symlink to trackinfo and make it filter the subs
import os
import sys
import argparse
import json
import xmltodict
from viddin import viddin
def build_argparser():
parser = argparse.ArgumentParser()
parser.add_argument("source", nargs="?", help="input file")
parser.add_argument("--title", help="title number to rip")
parser.add_argument("--lang", help="only use subtitles in specified language")
return parser
def main():
args = build_argparser().parse_args()
title = None
if args.title:
title = int(args.title)
if args.source:
source = args.source
else:
source = "/dev/dvd"
else:
source = args.source
if not os.path.exists(source):
print("%s does not exist" % (source))
sys.exit(1)
subs = getSubs(source, title)
for sub in subs:
info = "%i:" % (sub['rv_track_id'])
info += " Forced="
if 'forced_track' in sub and sub['forced_track']:
info += "Yes"
else:
info += "No"
if 'uid' in sub:
info += " UID=%i" % (sub['uid'])
if 'language' in sub:
lang = sub['language']
if args.lang and lang != args.lang:
continue
info += " Language=%s" % (lang)
if 'DURATION' in sub:
info += " Duration=%s" % (sub['DURATION'])
if 'NUMBER_OF_FRAMES' in sub:
info += " Frames=%s" % (sub['NUMBER_OF_FRAMES'])
if 'NUMBER_OF_BYTES' in sub:
info += " Bytes=%s" % (sub['NUMBER_OF_BYTES'])
if 'codec_id' in sub:
info += " Codec=%s" % (sub['codec_id'])
print(info)
return
if __name__ == '__main__':
exit(main() or 0)