Ejemplo n.º 1
0
    def __init__(self, mountpoint="/mnt/ipod", local=False, localdb=None):
        """Create a Database object.

        You can create the object from a mounted iPod or from a local
        database file.

        To use a mounted iPod:

            db = gpod.Database('/mnt/ipod')

        To use a local database file:

            db = gpod.Database(localdb='/path/to/iTunesDB')

        If you specify local=True then the default local database from
        gtkpod will be used (~/.gtkpod/local_0.itdb):

            db = gpod.Database(local=True)

        """

        if local or localdb:
            if localdb:
                self._itdb_file = localdb
            else:
                self._itdb_file = os.path.join(os.environ['HOME'],
                                               ".gtkpod",
                                               "local_0.itdb")
            self._itdb = gpod.itdb_parse_file(self._itdb_file, None)
        else:
            self._itdb = gpod.itdb_parse(mountpoint, None)
            if not self._itdb:
                raise DatabaseException("Unable to parse iTunes database at mount point %s" % mountpoint)
            else:
                self._itdb.mountpoint = mountpoint
            self._itdb_file = gpod.itdb_get_itunesdb_path(
                                gpod.itdb_get_mountpoint(self._itdb)
                              )
        self._load_gtkpod_extended_info()
Ejemplo n.º 2
0
    def __init__(self, mountpoint="/mnt/ipod", local=False, localdb=None):
        """Create a Database object.

        You can create the object from a mounted iPod or from a local
        database file.

        To use a mounted iPod:

            db = gpod.Database('/mnt/ipod')

        To use a local database file:

            db = gpod.Database(localdb='/path/to/iTunesDB')

        If you specify local=True then the default local database from
        gtkpod will be used (~/.gtkpod/local_0.itdb):

            db = gpod.Database(local=True)

        """

        if local or localdb:
            if localdb:
                self._itdb_file = localdb
            else:
                self._itdb_file = os.path.join(os.environ['HOME'], ".gtkpod",
                                               "local_0.itdb")
            self._itdb = gpod.itdb_parse_file(self._itdb_file, None)
        else:
            self._itdb = gpod.itdb_parse(mountpoint, None)
            if not self._itdb:
                raise DatabaseException(
                    "Unable to parse iTunes database at mount point %s" %
                    mountpoint)
            else:
                self._itdb.mountpoint = mountpoint
            self._itdb_file = gpod.itdb_get_itunesdb_path(
                gpod.itdb_get_mountpoint(self._itdb))
        self._load_gtkpod_extended_info()
Ejemplo n.º 3
0
##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

##  $Id$

import os, os.path
import gpod
import sys
from xml import xpath
from xml.dom import minidom
from xml.parsers.expat import ExpatError
import urllib2, urllib

TRUST_LIMIT = 10
dbname = os.path.join(os.environ['HOME'], ".gtkpod/local_0.itdb")

itdb = gpod.itdb_parse_file(dbname, None)
if not itdb:
    print "Failed to read %s" % dbname
    sys.exit(2)

cache = {}
for track in gpod.sw_get_tracks(itdb):
    if track.artist is None:
        continue

    key = track.artist.upper()
    if not cache.has_key(key):
        url = "http://ws.audioscrobbler.com/1.0/artist/%s/toptags.xml" % urllib.quote(
            track.artist)

        try:
##  $Id$


import os, os.path
import gpod
import sys
from xml import xpath
from xml.dom import minidom
from xml.parsers.expat import ExpatError
import urllib2, urllib

TRUST_LIMIT = 10
dbname = os.path.join(os.environ['HOME'],".gtkpod/local_0.itdb")


itdb = gpod.itdb_parse_file(dbname, None)
if not itdb:
    print "Failed to read %s" % dbname
    sys.exit(2)
    
cache={}
for track in gpod.sw_get_tracks(itdb):
    if track.artist is None:
        continue

    key = track.artist.upper()
    if not cache.has_key(key):
        url = "http://ws.audioscrobbler.com/1.0/artist/%s/toptags.xml" % urllib.quote(track.artist)
        
        try:
            reply    = urllib2.urlopen(url).read()