-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python 3 compatibility with six + demo.py added
- Loading branch information
Showing
2 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
|
||
""" | ||
a demo that shows how to call pymediainfo | ||
""" | ||
|
||
from __future__ import (absolute_import, division, | ||
print_function, unicode_literals) | ||
|
||
import sys | ||
from pprint import pprint | ||
|
||
from pymediainfo import MediaInfo | ||
|
||
|
||
def print_frame(text): | ||
print("+-{}-+".format("-" * len(text))) | ||
print("| {} |".format(text)) | ||
print("+-{}-+".format("-" * len(text))) | ||
|
||
|
||
def process(fname): | ||
media_info = MediaInfo.parse(fname) | ||
for track in media_info.tracks: | ||
print_frame(track.track_type) | ||
pprint(track.to_data()) | ||
# | ||
print() | ||
for track in media_info.tracks: | ||
if track.track_type == 'General': | ||
print("Duration: {} sec.".format(track.duration / 1000.0)) | ||
|
||
############################################################################## | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) == 1: | ||
print("Usage: {} <media_file>".format(sys.argv[0])) | ||
sys.exit(0) | ||
# else | ||
process(sys.argv[1]) |
This file contains 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