Commits

Josep Batalle  committed ba3134d

Errors and readme

  • Participants
  • Parent commits 7ad1b41

Comments (0)

Files changed (5)

 Download this script and put it into scripts directory (usually ~/.kde/share/apps/amarok/scripts/). Then, active the script in your Amarok 
 configuration.
 
-Once the plugin is installed, you can see a new option in Tools Menu. Here you have to put your google account. Then, you can see a new 
-collection with your songs.
+IMPORTANT
+You need to give execution permissions to the google_music.sh file.
+
+You can use the following command: 
+
+  chmod +x ~/.kde4/share/apps/amarok/scripts/google_music/google_music.sh
+  
+or if you stay inside the folder:
+
+  chmod +x google_music.sh
+
+Once the plugin is installed, you can see a new option in Tools Menu. Here you have to put your google account. Then, you can download the 
+list of songs pushing the button allocated in the Tools Menu ("Update Google Music List"). After a few seconds, AMarok shows an alert in 
+order to confirm the correct downloaded. Then restart Amarok to check the list of songs downloaded.
 
 At this moment is only a basic system, works fine but needs more little changes in order to improve the reliability.
 Amarok.Window.ToolsMenu.updateList['triggered()'].connect(updateListJson);
 
 function updateListJson() {
-    executeScript();
+    var state = executeScript("default");
     update = false;
     newItems();
-    Amarok.alert("Your music list is updated... Restart Amarok please.");
+    if(state == '')
+      var state = executeScript("option1);
+    if(state != '')
+      Amarok.alert("Your music list is updated... Restart Amarok please.");
 }
 
 function configurationEditor() {

File docs/README.txt

 This script allows you to listen your music allocated in your account in Google Music in your Amarok player.
 
 INSTRUCTIONS
-Download this script and put it into scripts directory (usually ~/.kde/share/apps/amarok/scripts/). Then, active the script in your Amarok
+Download this script and put it into scripts directory (usually ~/.kde/share/apps/amarok/scripts/). Then, active the script in your Amarok 
 configuration.
 
-Once the plugin is installed, you can see a new option in Tools Menu. Here you have to put your google account. Then, you can see a new
-collection with your songs.
+IMPORTANT
+You need to give execution permissions to the google_music.sh file.
+
+You can use the following command: 
+
+  chmod +x ~/.kde4/share/apps/amarok/scripts/google_music/google_music.sh
+  
+or if you stay inside the folder:
+
+  chmod +x google_music.sh
+
+Once the plugin is installed, you can see a new option in Tools Menu. Here you have to put your google account. Then, you can download the 
+list of songs pushing the button allocated in the Tools Menu ("Update Google Music List"). After a few seconds, AMarok shows an alert in 
+order to confirm the correct downloaded. Then restart Amarok to check the list of songs downloaded.
 
 At this moment is only a basic system, works fine but needs more little changes in order to improve the reliability.

File google_music.sh

 	email=$1
 	password=$2
    authResponse=$(curl "$clientLoginUrl" --data-urlencode Email="$email" --data-urlencode Passwd="$password" -d accountType=GOOGLE -d service="$service")
-   authToken="${authResponse##*=}"
-   SID="${authResponse:4:288}"
-   LID="${authResponse:298:288}"
-   return $SID
+   authToken="$(echo "$authResponse" | egrep "^Auth=" | cut -d= -f2-)"
+  SID="$(echo "$authResponse" | egrep "^SID=" | cut -d= -f2-)"
+  LID="$(echo "$authResponse" | egrep "^LID=" | cut -d= -f2-)"
+  [ "$SID" ] || return 1
+  return 0
 }
 
 function listSongs(){
-	curl --header "Authorization: GoogleLogin auth=${authToken}"      https://www.googleapis.com/sj/v1beta1/tracks > listSongs.json
+	curl --header "Authorization: GoogleLogin auth=${authToken}"      https://www.googleapis.com/sj/v1beta1/tracks > ListSongs.json
 }
 
 function getCookie() {
 getList="getList"
 getUrlSong="getUrlSong"
 
+	echo $getUrlSong>return.txt
+
 if [ "$action" == "$getList" ]; then
 	email=$2
 	password=$3
 	auth $email $password
 	return_val=$?
 	echo $return_val>return.txt
-	if [ "$?" == "" ]; then
+	if [ $return_val -ne 0 ]; then
 		echo "offline"
 		echo $return_val>return.txt
-	elif [ "$?" != "" ]; then
+	else
 		listSongs 
 		getCookie $email $password 
 	fi
     else false;
 }
 
-function executeScript() {
+function executeScript(type) {
     Config["gpUserID"] = Amarok.Script.readConfig("gpUserID", "");
     Config["gpPass"] = Amarok.Script.readConfig("gpPass", "");
-    var dirScript = "../.kde4/share/apps/amarok/scripts/google_music/"; //~/Documents by default
+    if(type == "default")
+      var dirScript = ".kde4/share/apps/amarok/scripts/google_music/"; //~/Documents by default
+    else
+      var dirScript = "../.kde4/share/apps/amarok/scripts/google_music/"; //~/Documents by default other systems
     var nameScript = "google_music.sh";
+    
     var args = new Array();
     args[0] = nameScript;
     args[1] = "getList";
     args[2] = Config["gpUserID"];
     args[3] = Config["gpPass"];
-
     var p = new QProcess();
     p.setWorkingDirectory(dirScript);
     p.start("sh", args, QIODevice.ReadOnly);
     var Response = p.readAllStandardOutput();
     var textStream = new QTextStream(Response, QIODevice.ReadOnly);
     var tinyURL = textStream.readAll();
+    return tinyURL;
 }
 
 function getUrl(id) {
-    var dirScript = "../.kde4/share/apps/amarok/scripts/google_music/"; //~/Documents by default
+    if(type == "default")
+      var dirScript = ".kde4/share/apps/amarok/scripts/google_music/"; //~/Documents by default
+    else
+      var dirScript = "../.kde4/share/apps/amarok/scripts/google_music/"; //~/Documents by default other systems
     var nameScript = "google_music.sh"; //getUrl
     var args = new Array();
     args[0] = nameScript;