コード例 #1
0
ファイル: Functions.cs プロジェクト: DariusKing/Nisme
        public static void LoadUser(bool force)
        {
            string filename = GetMyDocumentsDir() + "\\" + Lala.API.Instance.CurrentUser.UserID + ".nlf";

            if (File.Exists(filename) && force == false)
            {
                FileStream      fs = new FileStream(filename, FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                Lala.API.Instance.CurrentUser = (API.User)bf.Deserialize(fs);
                fs.Close();
                Lala.API.Instance.CurrentUser.Queue = new List <Song>();
            }
            else
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                Lala.API.Instance.CurrentUser.Library.Playlists.Add(new Playlist(API.HTTPRequests.GetLibrary(Lala.API.Instance.CurrentUser.TotalCount, 0), "My Collection", "songs"));
                Hashtable             pls = HTTPRequests.GetPlaylists();
                IDictionaryEnumerator en  = pls.GetEnumerator();
                while (en.MoveNext())
                {
                    string URL = "http://www.lala.com/api/Playlists/getOwnSongs/" + API.Functions.CurrentLalaVersion() + "?playlistToken=" + en.Key.ToString() + "&includeHistos=false&count=1000&skip=0&sortKey=Offset&sortDir=Asc&webSrc=nisme";
                    Lala.API.Instance.CurrentUser.Library.Playlists.Add(new Playlist(URL, en.Value.ToString(), en.Key.ToString()));
                }
                Lala.API.Instance.CurrentUser.Queue = new List <Song>();
                SaveLibrary();
            }
        }
コード例 #2
0
ファイル: User.cs プロジェクト: DariusKing/Nisme
        public User()
        {
            JObject info = HTTPRequests.GetUserInfo();

            Username     = (string)info["nickName"];
            UserID       = (string)info["userToken"];
            EmailAddress = (string)info["email"];
            TotalCount   = API.Functions.GetTrackCount();
            Library      = new Library();
            Queue        = new List <Song>();
            Listened     = new List <Song>();
        }
コード例 #3
0
ファイル: Playlist.cs プロジェクト: DariusKing/Nisme
        public Playlist(string URL, string Name, string ID)
        {
            //API.XmlParser parser = new API.XmlParser();
            //XPathNavigator nav = parser.XPathNavFromStream(URL);
            //List<Object> placeholder = parser.SingleNodeCollection(typeof(Song), XPathStatements.Playlists.Songs, nav);
            //ConvertFrom(placeholder);
            this.Histos = new List <Histo>();
            this.Songs  = new List <Song>();
            API.JSONParser parser = new API.JSONParser();
            string         json   = HTTPRequests.GetData(URL);
            JObject        o      = JObject.Parse(json);
            JArray         pls    = (JArray)o["data"]["tracks"]["list"];
            Hashtable      ht     = new Hashtable();

            foreach (JObject item in pls)
            {
                Songs.Add(new Song(item));
            }
            this.Name = Name;
            this.ID   = ID;
        }