コード例 #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();
            }
        }