Example #1
0
def findArtistbyAlbum(name):

    myDB = db.DBConnection()

    artist = myDB.action(
        'SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL ORDER BY RANDOM()',
        [name]).fetchone()

    if not artist:
        return False

    # Probably not neccessary but just want to double check
    if not artist['AlbumTitle']:
        return False

    term = '"' + artist['AlbumTitle'] + '" AND artist:"' + name + '"'

    results = None

    try:
        results = musicbrainzngs.search_release_groups(term).get(
            'release-group-list')
    except WebServiceError, e:
        logger.warn('Attempt to query MusicBrainz for %s failed (%s)' %
                    (name, str(e)))
        time.sleep(5)
Example #2
0
def findArtistbyAlbum(name):

    # Somehow non unicode is getting passed into this function?
    if not isinstance(name, unicode):
        try:
            name = name.decode('latin-1', 'replace')
        except:
            try:
                name = name.decode(headphones.SYS_ENCODING, 'replace')
            except:
                logger.warn("Unable to convert artist to unicode so cannot do a database lookup")
                return False

    myDB = db.DBConnection()
    
    artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL ORDER BY RANDOM()', [name]).fetchone()
    
    if not artist:
        return False
        
    # Probably not neccessary but just want to double check
    if not artist['AlbumTitle']:
        return False

    term = '"'+artist['AlbumTitle']+'" AND artist:"'+name+'"'

    results = None
    
    try:
        results = musicbrainzngs.search_release_groups(term).get('release-group-list')
    except WebServiceError, e:
        logger.warn('Attempt to query MusicBrainz for %s failed (%s)' % (name, str(e)))
        time.sleep(5)    
Example #3
0
def findAlbumID(artist=None, album=None):

    results = None
    
    try:
        term = '"'+album+'" AND artist:"'+artist+'"'
        results = musicbrainzngs.search_release_groups(term,1).get('release-group-list')
    except WebServiceError, e:
        logger.warn('Attempt to query MusicBrainz for %s - %s failed (%s)' % (artist, album, str(e)))
        time.sleep(5)
Example #4
0
def findAlbumID(artist=None, album=None):

    results = None
    
    try:
        term = '"'+album+'" AND artist:"'+artist+'"'
        results = musicbrainzngs.search_release_groups(term,1).get('release-group-list')
    except WebServiceError, e:
        logger.warn('Attempt to query MusicBrainz for %s - %s failed (%s)' % (artist, album, str(e)))
        time.sleep(5)
Example #5
0
def findArtistbyAlbum(name):

    myDB = db.DBConnection()
    
    artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL ORDER BY RANDOM()', [name]).fetchone()
    
    if not artist:
        return False
        
    # Probably not neccessary but just want to double check
    if not artist['AlbumTitle']:
        return False

    term = '"'+artist['AlbumTitle']+'" AND artist:"'+name+'"'

    results = None
    
    try:
        results = musicbrainzngs.search_release_groups(term).get('release-group-list')
    except WebServiceError, e:
        logger.warn('Attempt to query MusicBrainz for %s failed (%s)' % (name, str(e)))
        time.sleep(5)    
Example #6
0
def findAlbumID(artist=None, album=None):

    results = None
    chars = set('!?*-')

    try:
        if album and artist:
            if any((c in chars) for c in album):
                album = '"'+album+'"'
            if any((c in chars) for c in artist):
                artist = '"'+artist+'"'
            criteria = {'release': album.lower()}
            criteria['artist'] = artist.lower()
        else:
            if any((c in chars) for c in album):
                album = '"'+album+'"'
            criteria = {'release': album.lower()}

        results = musicbrainzngs.search_release_groups(limit=1, **criteria).get('release-group-list')
    except WebServiceError, e:
        logger.warn('Attempt to query MusicBrainz for %s - %s failed (%s)' % (artist, album, str(e)))
        time.sleep(5)