From 2e25337cc11bc8fec4ceef895d9d9421e8583f0c Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Thu, 22 Dec 2011 23:59:16 +0100 Subject: [PATCH] Small changes in groovesharkparser --- src/libtomahawk/utils/groovesharkparser.cpp | 58 ++++++++++----------- src/libtomahawk/utils/groovesharkparser.h | 10 +++- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/libtomahawk/utils/groovesharkparser.cpp b/src/libtomahawk/utils/groovesharkparser.cpp index 8fc95ebca..6ee245c56 100644 --- a/src/libtomahawk/utils/groovesharkparser.cpp +++ b/src/libtomahawk/utils/groovesharkparser.cpp @@ -1,5 +1,7 @@ /* === This file is part of Tomahawk Player - === * + * Copyright 2010-2011, Leo Franchi + * Copyright 2010-2011, Hugo Lindström * Copyright 2010-2011, Stefan Derkits * * Tomahawk is free software: you can redistribute it and/or modify @@ -49,6 +51,14 @@ GroovesharkParser::GroovesharkParser( const QStringList& trackUrls, bool createN , m_createNewPlaylist( createNewPlaylist ) , m_browseJob( 0 ) { + QByteArray magic = QByteArray::fromBase64( enApiSecret ); + + QByteArray wand = QByteArray::fromBase64( QCoreApplication::applicationName().toLatin1() ); + int length = magic.length(), n2 = wand.length(); + for ( int i=0; ipost( QNetworkRequest( url ), data ); connect( reply, SIGNAL( finished() ), this, SLOT( groovesharkLookupFinished() ) ); - //m_browseJob = new DropJobNotifier( pixmap(), "Grooveshark", type, reply ); - //JobStatusView::instance()->model()->addJob( m_browseJob ); + m_browseJob = new DropJobNotifier( pixmap(), "Grooveshark", type, reply ); + JobStatusView::instance()->model()->addJob( m_browseJob ); m_queries.insert( reply ); } @@ -157,13 +158,10 @@ GroovesharkParser::groovesharkLookupFinished() return; } - //tDebug() << "parsed grooveshark result into a map " << res; - //tDebug() << "results " << res.value("result") << " which is of type " << res.value("result").type(); - QVariantList list = res.value("result").toMap().value("songs").toList(); + QVariantList list = res.value( "result" ).toMap().value( "songs" ).toList(); foreach (const QVariant& var, list) { QVariantMap trackResult = var.toMap(); - //tDebug() << map; QString title, artist, album; @@ -173,7 +171,7 @@ GroovesharkParser::groovesharkLookupFinished() if ( title.isEmpty() && artist.isEmpty() ) // don't have enough... { - tLog() << "Didn't get an artist and track name from spotify, not enough to build a query on. Aborting" << title << artist << album; + tLog() << "Didn't get an artist and track name from grooveshark, not enough to build a query on. Aborting" << title << artist << album; return; } @@ -190,11 +188,11 @@ GroovesharkParser::groovesharkLookupFinished() if ( m_trackMode ) checkTrackFinished(); else - checkBrowseFinished(); + checkPlaylistFinished(); } void -GroovesharkParser::checkBrowseFinished() +GroovesharkParser::checkPlaylistFinished() { tDebug() << "Checking for grooveshark batch playlist job finished" << m_queries.isEmpty() << m_createNewPlaylist; if ( m_queries.isEmpty() ) // we're done @@ -252,7 +250,7 @@ QPixmap GroovesharkParser::pixmap() const { if ( !s_pixmap ) - s_pixmap = new QPixmap( RESPATH "images/spotify-logo.png" ); + s_pixmap = new QPixmap( RESPATH "images/grooveshark.png" ); return *s_pixmap; -} \ No newline at end of file +} diff --git a/src/libtomahawk/utils/groovesharkparser.h b/src/libtomahawk/utils/groovesharkparser.h index 7a62e87de..a387ed928 100644 --- a/src/libtomahawk/utils/groovesharkparser.h +++ b/src/libtomahawk/utils/groovesharkparser.h @@ -1,6 +1,8 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Stefan Derkits + * Copyright 2010-2011, Leo Franchi + * Copyright 2010-2011, Hugo Lindström + * Copyright 2011, Stefan Derkits * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +26,8 @@ #include "query.h" #include "jobview/JobStatusItem.h" +#include + #include #include #include @@ -62,7 +66,7 @@ private: void lookupUrl( const QString& url ); void lookupGroovesharkPlaylist( const QString& playlist ); void checkTrackFinished(); - void checkBrowseFinished(); + void checkPlaylistFinished(); int m_limit; bool m_trackMode; bool m_createNewPlaylist; @@ -72,6 +76,8 @@ private: Tomahawk::playlist_ptr m_playlist; DropJobNotifier* m_browseJob; + QCA::SymmetricKey m_apiKey; + static QPixmap* s_pixmap; };