Last active
September 19, 2020 16:04
-
-
Save wyyqyl/9e3158867c6497cba394a21756237656 to your computer and use it in GitHub Desktop.
ob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# coding=utf-8 | |
import sys | |
import re | |
bdinfo = {} | |
images = [] | |
def init(): | |
for line in sys.stdin: | |
line = line.strip().replace(' ', ' ') | |
line = re.sub(r'\[/?quote\]', '', line, flags = re.I) | |
if not line.strip(): | |
continue | |
if line[0] != '[': | |
key, value = line.split(':', 1) | |
key, value = key.strip(), value.strip() | |
if key not in bdinfo: | |
bdinfo[key] = value | |
else: | |
bdinfo[key] = bdinfo[key] + '\n' + value | |
else: | |
line = re.sub(r'\[url=.+?\]', '', line, flags = re.I) | |
line = re.sub(r'\[/url\]', '', line, flags = re.I) | |
for image in line.split(' '): | |
image = image.replace('thumbs2.imgbox.com', 'images.imgbox.com').replace('_t.png', '_o.png') | |
images.append(image) | |
def output_bdinfo(): | |
print('[quote]') | |
print('DISC INFO:') | |
print('') | |
if 'Disc Title' in bdinfo: | |
print('Disc Title: ' + bdinfo['Disc Title']) | |
if 'Disc Label' in bdinfo: | |
print('Disc Label: ' + bdinfo['Disc Label']) | |
print('Disc Size: ' + bdinfo['Disc Size']) | |
print('Protection: ' + bdinfo['Protection']) | |
print('Extras: BD-Java') | |
print('BDInfo: 0.7.5.5') | |
print('') | |
print('PLAYLIST REPORT:') | |
print('') | |
print('Name: ' + bdinfo['Playlist']) | |
print('Length: ' + bdinfo['Length'] + ' (h:m:s.ms)') | |
print('Size: ' + bdinfo['Size']) | |
print('Total Bitrate: ' + bdinfo['Total Bitrate']) | |
print('') | |
print('VIDEO:') | |
print('') | |
print('Codec Bitrate Description') | |
print('----- ------- -----------') | |
videos = bdinfo['Video'].split('\n') | |
for video in videos: | |
codec, bitrate, desc = video.split('/', 2) | |
print('{0:<24}{1:<20}{2}'.format(codec.strip(), bitrate.strip(), desc.strip())) | |
print('') | |
print('AUDIO:') | |
print('') | |
print('Codec Language Bitrate Description') | |
print('----- -------- ------- -----------') | |
audios = bdinfo['Audio'].split('\n') | |
for audio in audios: | |
lang, codec, desc = audio.split('/', 2) | |
_, _, bitrate, _ = desc.split('/', 3) | |
print('{0:<32}{1:<16}{2:<16}{3}'.format(codec.strip(), lang.strip(), bitrate.strip(), desc.strip())) | |
print('') | |
if 'Subtitle' not in bdinfo: | |
return | |
print('SUBTITLES:') | |
print('') | |
print('Codec Language Bitrate Description') | |
print('----- -------- ------- -----------') | |
subtitles = bdinfo['Subtitle'].split('\n') | |
for subtitle in subtitles: | |
lang, bitrate = subtitle.split('/', 1) | |
print('Presentation Graphics {0:<16}{1}'.format(lang.strip(), bitrate.strip())) | |
print('[/quote]') | |
def output(): | |
print('') | |
if len(bdinfo) > 0: | |
output_bdinfo() | |
for image in images: | |
print(image) | |
def main(): | |
init() | |
output() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment