void JamendoInfoParser::getInfo(AlbumPtr album) { DEBUG_BLOCK JamendoAlbum * jamendoAlbum = dynamic_cast<JamendoAlbum *> ( album.data() ); if ( jamendoAlbum == 0) return; QString description = jamendoAlbum->description(); if ( description.isEmpty() ) description = i18n( "No description available..." ); QString infoHtml = "<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" " "CONTENT=\"text/html; charset=utf-8\"></HEAD><BODY>"; infoHtml += "<div align=\"center\">"; infoHtml += i18n( "Album" ) + "<br><br>"; infoHtml += "<strong>"; infoHtml += jamendoAlbum->prettyName(); infoHtml += "</strong><br><br><em>"; if ( !jamendoAlbum->coverUrl().isEmpty() ) infoHtml += "<img src=\"" + jamendoAlbum->coverUrl() + "\" align=\"middle\" border=\"1\"><br><br>"; infoHtml += description; infoHtml += "<br><br>" + i18n( "From Jamendo.com" ) + "</div>"; infoHtml += "</BODY></HTML>"; emit( info( infoHtml ) ); }
TrackList AlbumMatcher::match( Collections::MemoryCollection *memColl ) { if( !m_album || !memColl ) return TrackList(); AlbumMap albumMap = memColl->albumMap(); if ( albumMap.contains( m_album ) ) // compares albums by value { AlbumPtr album = albumMap.value( m_album ); // compares albums by value, too TrackList matchingTracks = album->tracks(); if ( isLast() ) return matchingTracks; else return next()->match( matchingTracks ); } else return TrackList(); }
AlbumPtr ServiceSqlRegistry::getAlbum( const QStringList &rowData ) { int id = rowData[0].toInt(); QMutexLocker locker( &m_albumMutex ); if( m_albumMap.contains( id ) ) return m_albumMap.value( id ); else { int index = 0; QStringList testString = rowData.mid( index, m_metaFactory->getAlbumSqlRowCount() ); AlbumPtr albumPtr = m_metaFactory->createAlbum( rowData.mid(index, m_metaFactory->getAlbumSqlRowCount() ) ); m_albumMap.insert( id, albumPtr ); index += m_metaFactory->getAlbumSqlRowCount(); ServiceAlbum* album = static_cast<ServiceAlbum *> ( albumPtr.data() ); ArtistPtr artistPtr; // we need to set the artist for this album if ( m_artistMap.contains( album->artistId() ) ) artistPtr = m_artistMap.value( album->artistId() ); else { QStringList subRows = rowData.mid(index, m_metaFactory->getArtistSqlRowCount() ); artistPtr = m_metaFactory->createArtist( subRows ); } index += m_metaFactory->getArtistSqlRowCount(); ServiceArtist * artist = static_cast<ServiceArtist *> ( artistPtr.data() ); album->setAlbumArtist( artistPtr ); m_artistMap.insert( artist->id(), artistPtr ); return albumPtr; } }
void MagnatuneInfoParser::getInfo(AlbumPtr album) { showLoading( i18n( "Loading album info..." ) ); MagnatuneAlbum * magnatuneAlbum = dynamic_cast<MagnatuneAlbum *>( album.data() ); const QString artistName = album->albumArtist()->name(); QString infoHtml = "<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" " "CONTENT=\"text/html; charset=utf-8\"></HEAD><BODY>"; infoHtml += generateHomeLink(); infoHtml += "<div align=\"center\"><strong>"; infoHtml += artistName; infoHtml += "</strong><br><em>"; infoHtml += magnatuneAlbum->name(); infoHtml += "</em><br><br>"; infoHtml += "<img src=\"" + magnatuneAlbum->coverUrl() + "\" align=\"middle\" border=\"1\">"; // Disable Genre line in Magnatune applet since, well, it doesn't actually put a genre there... // Nikolaj, FYI: either the thumbnails aren't working, or they aren't getting through the proxy here. That would be odd, however, as the database and // all HTML are coming through the proxy //infoHtml += "<br><br>" + i18n( "Genre: ");// + magnatuneAlbum-> infoHtml += "<br>" + i18n( "Release Year: %1", QString::number( magnatuneAlbum->launchYear() ) ); if ( !magnatuneAlbum->description().isEmpty() ) { //debug() << "MagnatuneInfoParser: Writing description: '" << album->getDescription() << "'"; infoHtml += "<br><br><b>" + i18n( "Description:" ) + "</b><br><p align=\"left\" >" + magnatuneAlbum->description(); } infoHtml += "</p><br><br>" + i18n( "From Magnatune.com" ) + "</div>"; infoHtml += "</BODY></HTML>"; emit ( info( infoHtml ) ); }
TrackPtr ServiceSqlRegistry::getTrack( const QStringList &rowData ) { //test if rowData is the correct length int correctLength = m_metaFactory->getTrackSqlRowCount() + m_metaFactory->getAlbumSqlRowCount() + m_metaFactory->getArtistSqlRowCount() + m_metaFactory->getGenreSqlRowCount(); if ( rowData.size() != correctLength ) return Meta::TrackPtr(); int id = rowData[0].toInt(); QMutexLocker locker( &m_trackMutex ); if( m_trackMap.contains( id ) ) { return m_trackMap.value( id ); } else { int index = 0; TrackPtr trackPtr = m_metaFactory->createTrack( rowData.mid(index, m_metaFactory->getTrackSqlRowCount() ) ); index += m_metaFactory->getTrackSqlRowCount(); ServiceTrack * track = static_cast<ServiceTrack *> ( trackPtr.data() ); AlbumPtr albumPtr; if ( m_albumMap.contains( track->albumId() ) ) albumPtr = m_albumMap.value( track->albumId() ); else albumPtr = getAlbum( rowData.mid( index, rowData.count() -1 ) ); index += m_metaFactory->getAlbumSqlRowCount(); ServiceAlbum * album = static_cast<ServiceAlbum *> ( albumPtr.data() ); album->addTrack( trackPtr ); track->setAlbumPtr( albumPtr ); m_albumMap.insert( track->albumId(), albumPtr ); ArtistPtr artistPtr; if ( m_artistMap.contains( track->artistId() ) ) artistPtr = m_artistMap.value( track->artistId() ); else { QStringList subRows = rowData.mid(index, m_metaFactory->getArtistSqlRowCount() ); artistPtr = m_metaFactory->createArtist( subRows ); } index += m_metaFactory->getArtistSqlRowCount(); ServiceArtist * artist = static_cast<ServiceArtist *> ( artistPtr.data() ); artist->addTrack( trackPtr ); track->setArtist( artistPtr ); m_artistMap.insert( track->artistId(), artistPtr ); GenrePtr genrePtr; int genreId = rowData[index].toInt(); if( m_genreMap.contains( genreId ) ) genrePtr = m_genreMap.value( genreId ); else genrePtr = m_metaFactory->createGenre( rowData.mid(index, m_metaFactory->getGenreSqlRowCount() ) ); ServiceGenre * genre = dynamic_cast<ServiceGenre *> ( genrePtr.data() ); Q_ASSERT( genre ); if( genre ) genre->addTrack( trackPtr ); track->setGenre( genrePtr ); m_genreMap.insert( genreId, genrePtr ); m_trackMap.insert( id, trackPtr ); return trackPtr; } }
void ScriptableServiceInfoParser::getInfo(AlbumPtr album) { DEBUG_BLOCK ScriptableServiceAlbum * serviceAlbum = dynamic_cast< ScriptableServiceAlbum * >( album.data() ); if (serviceAlbum == 0) return; emit( info( serviceAlbum->description() ) ); if ( serviceAlbum->description().isEmpty() ) { showLoading( i18n( "Loading info..." ) ); ScriptManager::instance()->ServiceScriptRequestInfo( m_serviceName, serviceAlbum->level(), serviceAlbum->callbackString() ); } }