Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Reusing saved instances of Song doesn't work anymore #13

Open
Najtal opened this issue Mar 31, 2014 · 6 comments
Open

Reusing saved instances of Song doesn't work anymore #13

Najtal opened this issue Mar 31, 2014 · 6 comments

Comments

@Najtal
Copy link

Najtal commented Mar 31, 2014

Hi,

I finally found some time to work on my project using this api, repairing it from the last changes of google.
When I getAllSongs(...), I serialize them and save them into a file so that I don't have to download it all again next time I open the program. It used to work like a charm until now. I always receive a 404 when I reuse saved data.

Do you have any idea how to fix this ?

ps: I only serialize the Songs, I don't serialize the api.

Regards

@vokke
Copy link
Collaborator

vokke commented Mar 31, 2014

I had a 404 when I started with gmusic as well. I changed the ApiExample to this:
This works on my local tomcat without any error.
Cheers,
Vokke

private static void testcase(PrintWriter out) { String password = ""; String username = ""; out.println(Calendar.getInstance().getTime()+"
"); IGoogleMusicAPI api = new GoogleMusicAPI(); try { new GoogleMusicAPI().login(username, password); } catch(Exception e) { e.printStackTrace(); }
    try
    {
        api.login(username, password);

        Collection<Song> tsongs = api.getAllSongs();

        for(Song track : tsongs) {
            if(track.getType()==1) 
            {
                out.println("Artist: "+track.getArtist()+" Track: "+track.getName()+"---"+track.getGenre()+" Date: "+new Date((long) track.getCreationDate())+"</br>");
                out.println("AlbumArt: <a href=\""+track.getAlbumArtUrl()+"\">"+track.getAlbumArtUrl()+"</a></br>");
                out.println("DL: <a href=\""+track.getUrl()+"\">"+track.getUrl()+"</a></br>");
                out.println("Duration: "+new SimpleDateFormat("mm:ss").format(new Date(track.getDurationMillis()))+"</br>");
                out.println("Type: "+track.getType()+"</br>");
                out.println("Playcount: "+track.getPlayCount()+"</br>");
                out.println("Rating: "+track.getRating()+"</br>");
                out.println("YEAR: "+track.getYear()+"</br>");
            }
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    out.println(Calendar.getInstance().getTime()+"</br>");
}

@jkiddo
Copy link
Owner

jkiddo commented Mar 31, 2014

I don't know what part you would like to reuse, probably the Url or something like that, and I think that could actually work. You do however need to remember that you still need to establish a session in order to use the url. Could that be the reason?

@SnoochieBoochies
Copy link

I believe I had the same issue a while back. If memory serves correctly, you need to have a valid session for the url to be valid. I think the session token forms part of the url, so when you re-open the app, that session token is likely invalid.
You could probably serialise all the data without the url for a song, then on some onClick() invocation, batch fetch songs for that album with a valid token. It's a while since I touched android so I might be wrong.

@Najtal
Copy link
Author

Najtal commented Apr 1, 2014

Thank you for your answers so far!

vokke: To be complete in the prog state.

  • I'm working on java for a desktop application
  • When I launch my program and there is no saved file, I ask for login, download all songs (getAllSongs()), generate library, serialize everything, save a copy in a file and it works perfectly.
  • When I launch my program and there is a saved library file, It load all the data, and when I try to get a url, it throws a 404 error.

jkiddo, I double checked and I'm doing the same connection steps in both situation.

SnoochieBoochies, It looks like you got an interesting point there, but I'm not sure I get it all. What is the session token and how is it represented in the connection/session ?
If I serialize the whole GoogleMusicAPI() instance, would it keep the same session token ? What could be another way to do it ?

Thanks for your quick answers ! :)

@jkiddo
Copy link
Owner

jkiddo commented Jan 31, 2015

The session token is established in memory when you log in - which means that it does not makes sense to serialize it as it is the tokes are produced serverside, not client side. You need to establish a session when using the API - and what is the library file?

@jkiddo
Copy link
Owner

jkiddo commented Mar 2, 2015

Damn - there definitely is an error! I was fooled by a cache - so are so true. It is currently not possible to get any urls and thereby not possible to download anything. I really need help to maintain this API. Does anyone of you guys have the time to help me out and get it up to date? It still seems like Simon Weber is keeping his implementation in Python up-to-date so apparently all the dirty work has already been done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants