Permalink
Browse files

i really want this to be done

  • Loading branch information...
1 parent 8e56296 commit bb4accf9afc8358cdc5d4dc39bd42313a0ce0bb7 @antimatter15 committed Mar 28, 2012
Showing with 32 additions and 12 deletions.
  1. +1 −1 manifest.json
  2. +30 −10 upload.js
  3. +1 −1 uploader.html
View
@@ -1,6 +1,6 @@
{
"name": "MusicAlpha",
- "version": "2.1",
+ "version": "2.2",
"description": "Upload songs to Google Music.",
"permissions": [
"cookies",
View
@@ -94,6 +94,15 @@ function protopost(path, proto, resp, callback){
xhr.onload = function(){
//console.log(xhr.response)
var array = new Uint8Array(xhr.response);
+ if(array.length > 140){
+ var str = [].slice.call(array,0).map(function(e){
+ return String.fromCharCode(e)
+ }).join('');
+ if(/Error 403/.test(str) && /^\<\!DOCTYPE/i.test(str)){
+ callback(null);
+ return;
+ }
+ }
//console.log(array);
resp.ParseFromArray([].slice.call(array,0));
callback(resp);
@@ -102,18 +111,21 @@ function protopost(path, proto, resp, callback){
function UploadAuth(callback){
var uauth = new SkyJam.UploadAuth();
- uauth.hostname = "musicalpha";
+ uauth.hostname = HostName;
uauth.address = MAC;
protopost('upauth', uauth, new SkyJam.UploadAuthResponse(), function(e){
//console.log(e);
- callback();
+ callback(e);
})
}
function ClientState(callback){
var cstate = new SkyJam.ClientState();
cstate.address = MAC;
protopost('clientstate', cstate, new SkyJam.ClientStateResponse(), function(e){
+ if(!e){
+ alert("Error retrieving current client state.");
+ }
var quota = e.quota;
console.log(quota.totalTracks, quota.maximumTracks);
callback(quota)
@@ -256,9 +268,13 @@ function UploadFile(file, params){
var SID = '';
-//if(!localStorage.uuid) localStorage.uuid = "musicalpha-"+Math.random();
-var MAC = '13:32:42:'+SHA1("musicalpha").replace(/(..)/g,'$1:').slice(0, 8); //pseudo-MAC;
+if(!localStorage.uuid){
+ var d = new Date();
+ localStorage.uuid = "MusicAlpha-"+Math.floor(1000000000*Math.random());
+}
+var HostName = localStorage.uuid;
+var MAC = '13:32:42:'+SHA1(localStorage.uuid).replace(/(..)/g,'$1:').slice(0, 8); //pseudo-MAC;
function checkLogin(){
@@ -275,12 +291,16 @@ function checkLogin(){
SID = info.value;
document.getElementById('uploader').style.display = '';
document.getElementById('login').style.display = 'none';
- UploadAuth(function(){
- document.getElementById('uploader').style.opacity = '1';
-
- ClientState(function(quota){
- updatePolar((quota.totalTracks + quota.availableTracks) / quota.maximumTracks, 1)
- })
+ UploadAuth(function(e){
+ if(e){
+ document.getElementById('uploader').style.opacity = '1';
+
+ ClientState(function(quota){
+ updatePolar((quota.totalTracks + quota.availableTracks) / quota.maximumTracks, 1)
+ })
+ }else{
+ alert("Error trying to authenticate uploader.")
+ }
})
}
})
View
@@ -137,7 +137,7 @@
</div>
<div id="center">
<div id="inner">
- <h1 style="float:right">v<span style="color:gray">2.1</span></h1>
+ <h1 style="float:right">v<span style="color:gray">2.2</span></h1>
<h1>Music<span style="color:gray">Alpha</span></h1>
<p>
This is a simple uploader for <a target=_blank href="https://play.google.com/music/listen">Google Play</a> built by <a target=_blank href="http://twitter.com/antimatter15">@antimatter15</a>, made possible by <a target=_blank href="http://github.com/antimatter15/google-music-protocol">reverse engineering</a> the official desktop uploader.

0 comments on commit bb4accf

Please sign in to comment.