forked from JonnyJD/python-discid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.py
executable file
·33 lines (26 loc) · 1.09 KB
/
examples.py
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
#!/usr/bin/env python
# Copyright (C) 2013 Johannes Dewender
# This example is free. You can redistribute and/or modify it at will.
# this will load Libdiscid
import discid
def simple_example():
disc = discid.read() # use default device
print("id: %s" % disc.id)
print("used %s as device" % discid.DEFAULT_DEVICE)
print("submit with:\n%s" % disc.submission_url)
def _length_str(seconds, sectors):
return "{min:>2.0f}:{sec:>02.0f} ({sectors:>6})".format(
min=(seconds // 60), sec=(seconds % 60), sectors=sectors)
def complex_example():
disc = discid.read("/dev/cdrom", ["mcn", "isrc"])
print("id:\t%s" % disc.id)
print("MCN:\t%s" % disc.mcn)
print("length:\t%s" % _length_str(disc.seconds, disc.sectors))
for track in disc.tracks:
length = _length_str(track.seconds, track.sectors)
print("{num:>2}: {offset:>6} {len}\tISRC: {isrc:13}".format(
num=track.number, offset=track.offset, len=length, isrc=track.isrc))
if __name__ == "__main__":
simple_example()
#complex_example()
# vim:set shiftwidth=4 smarttab expandtab: