/usr/share/doc/python-musicbrainz2-doc/examples/findtrack.py is in python-musicbrainz2-doc 0.7.4-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #! /usr/bin/env python
#
# Search for a track by title (and optionally by artist name).
#
# Usage:
# python findtrack.py 'track name' ['artist name']
#
# $Id: findtrack.py 201 2006-03-27 14:43:13Z matt $
#
import sys
import logging
from musicbrainz2.webservice import Query, TrackFilter, WebServiceError
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
if len(sys.argv) < 2:
print "Usage: findtrack.py 'track name' ['artist name']"
sys.exit(1)
if len(sys.argv) > 2:
artistName = sys.argv[2]
else:
artistName = None
q = Query()
try:
f = TrackFilter(title=sys.argv[1], artistName=artistName)
results = q.getTracks(f)
except WebServiceError, e:
print 'Error:', e
sys.exit(1)
for result in results:
track = result.track
print "Score :", result.score
print "Id :", track.id
print "Title :", track.title
print "Artist :", track.artist.name
print
# EOF
|