cddb info.py :  » Business-Application » CDDB.py » CDDB-1.4 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » CDDB.py 
CDDB.py » CDDB 1.4 » cddb-info.py
#!/usr/bin/env python

# Example of how to use CDDB.py and DiscID.py

# Written 17 Nov 1999 by Ben Gertzfield <che@debian.org
# This work is released under the GNU GPL, version 2 or later.

# Release version 1.4

import DiscID, CDDB, sys, os

dev = None
cdrom = None

if len(sys.argv) >= 2:
    dev = sys.argv[1]

if dev:
    cdrom = DiscID.open(dev)
else:
    cdrom = DiscID.open()

print "Getting disc id in CDDB format...",

disc_id = DiscID.disc_id(cdrom)

print "Disc ID: %08lx Num tracks: %d" % (disc_id[0], disc_id[1])
print "Querying CDDB for info on disc...",

(query_stat, query_info) = CDDB.query(disc_id)

if query_stat == 200:
    print ("success!\nQuerying CDDB for track info of `%s'... " % 
     query_info['title']),

    (read_stat, read_info) = CDDB.read(query_info['category'], 
               query_info['disc_id'])
    if read_stat == 210:
  print "success!"
          # Start from 0, not 1
          # thanks to bgp for the fix!
  for i in range(0, disc_id[1]):
      print "Track %.02d: %s" % (i+1, read_info['TTITLE' + `i`])
    else:
  print "failure getting track info, status: %i" % read_stat

elif query_stat == 210 or query_stat == 211:
    print "multiple matches found! Matches are:"
    for i in query_info:
  print "ID: %s Category: %s Title: %s" % \
        (i['disc_id'], i['category'], i['title'])

else:
    print "failure getting disc info, status %i" % query_stat


  
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.