Beispiel #1
0
    public void Load()
    {
        var dbContext = this._database.Context;

        var tracksByPlaylist = dbContext.PlaylistTracks
                               .GroupBy(t => t.PlaylistId)
                               .ToDictionary(t => t.Key);

        var playlists = dbContext.Playlists.Select(i =>
        {
            var playlist = new PlaylistInfo(i);
            if (tracksByPlaylist.TryGetValue(i.Id, out var playlistTracks))
            {
                var trackIds = playlistTracks.Select(t => t.TrackId).ToHashSet();
                var tracks   = this._trackManager
                               .Where(t => trackIds.Contains(t.Id))
                               .Select(t => new PlaylistTrackInfo(playlist, t));

                playlist.Playlist.Tracks.AddRange(tracks);
            }

            return(playlist);
        });

        this.Playlists.AddRange(playlists);
    }
        /// <summary>
        /// 更新播放列表,并写入文件
        /// </summary>
        /// <param name="model">播放列表</param>
        /// <returns>成功写入返回true,否则返回false</returns>
        private bool WritePlayListToFile(PlaylistInfo model)
        {
            XmlDocument xmlDoc = new XmlDocument();
            //获取应用程序所在文件夹
            string FilePath = PlayerSetting.DefaultVideosPath + "PlayList.xml";

            try
            {
                if (model == null)
                {
                    return(false);
                }
                xmlDoc.LoadXml(model.ToXml());
                DirectoryInfo d = new DirectoryInfo(PlayerSetting.DefaultVideosPath);
                if (!d.Exists)
                {
                    d.Create();
                }
                xmlDoc.Save(FilePath);
                return(true);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(ex.Message);
                return(false);
            }
        }
        private static void BuildPlaylistInfo(ref SearchResponse response, ref Utf8JsonReader reader)
        {
            var playlist = new PlaylistInfo();

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    break;
                }

                if (reader.TokenType != JsonTokenType.PropertyName)
                {
                    continue;
                }

                var index = reader.ValueSpan[0];
                reader.Read();

                if (index == 110)
                {
                    playlist.WithName(reader.GetString());
                }

                if (index == 115)
                {
                    playlist.WithTrack(reader.GetInt32());
                }
            }

            response.Playlist = playlist;
        }
        private PlaylistInfo searchTreeRecursive(PlaylistInfo tree, PlaylistInfo find)
        {
            if (tree.FolderID == find.FolderID)
            {
                return(tree);
            }

            foreach (PlaylistInfo playlist in tree.Children)
            {
                if (playlist.PlaylistType == libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_START_FOLDER)
                {
                    if (playlist.FolderID == find.FolderID)
                    {
                        return(playlist);
                    }

                    PlaylistInfo p2 = searchTreeRecursive(playlist, find);

                    if (p2 != null)
                    {
                        return(p2);
                    }
                }
            }

            return(null);
        }
        public override async Task SetPlaylist(MusicItem song)
        {
            // TODO remove
            await SubmitDownload(song);

            var newPlaylist = new PlaylistInfo(AudioConversions.ToPlaylistTrack(song));

            await SavePlaylist(newPlaylist);
        }
Beispiel #6
0
        /// <summary>
        /// 从本地载入播放列表
        /// </summary>
        public bool LoadPlayList()
        {
            try
            {
                string xmlDocPath = PlayerSetting.DefaultVideosPath + "PlayList.xml";
                if (System.IO.File.Exists(xmlDocPath))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(xmlDocPath);
                    PlaylistInfo plm = PlaylistInfo.ToModel(xmlDoc.OuterXml);
                    //播放列表赋值
                    plists = plm.MediaPlayList;
                    //计算整个播放列表播放时间的间隔加上循环间隔时长
                    playListTimeLength = 0;
                    //foreach (PlaylistItemInfo item in plists)
                    //{

                    //    playListTimeLength += item.PlayTime;
                    //}
                    for (int i = 0; i < plists.Count; i++)
                    {
                        string relativurl = plists[i].MediaFileName;
                        string path       = PlayerSetting.DefaultVideosPath + relativurl;
                        string md5Value   = plists[i].MD5Key;
                        if (!string.IsNullOrEmpty(md5Value))
                        {
                            string MediaMd5 = SeatManage.SeatManageComm.SeatComm.GetMD5HashFromFile(path);
                            if (MediaMd5.Equals(md5Value))
                            {
                                playListTimeLength += plists[i].PlayTime;
                            }
                            else
                            {
                                PlayListHandleEvent(this, string.Format("文件{0} MD5校验失败!", relativurl));
                                plists.RemoveAt(i);
                                i--;
                            }
                        }
                    }
                    //TODO:根据当前时间重新排列播放列表
                    RearrangePlayList();
                    return(true);
                }
                else
                {
                    SeatManage.SeatManageComm.WriteLog.Write("播放列表不存在");
                    PlayListHandleEvent(this, "本地播放列表不存在!");
                    return(false);
                }
            }
            catch
            {
                SeatManage.SeatManageComm.WriteLog.Write("载入播放列表失败");
                PlayListHandleEvent(this, "载入播放列表失败!");
                return(false);
            }
        }
Beispiel #7
0
        private void gridlist_gridview_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PlaylistInfo myobject = (sender as LongListSelector).SelectedItem as PlaylistInfo;


            if (myobject != null)
            {
                NavigationService.Navigate(new Uri("/View/PlaylistChannelPage.xaml?msg=" + myobject.Id, UriKind.Relative));
            }
        }
Beispiel #8
0
    /// <summary>
    /// プレイリスト情報を削除する
    /// </summary>
    /// <param name="playlist"></param>
    public void Delete(PlaylistInfo playlist)
    {
        this._database.Context.Playlists.Delete(new BsonValue(playlist.Id));

        this.Playlists.Remove(playlist);

        this._database.Context.PlaylistTracks.DeleteMany(i => i.PlaylistId == playlist.Id);

        playlist.Playlist.Tracks.Clear();
    }
Beispiel #9
0
    public void Delete(PlaylistInfo playlist, ICollection <TrackInfo> tracks)
    {
        var trackIds = tracks.Select(i => i.Id).ToHashSet();

        this._database.Context.PlaylistTracks.DeleteMany(
            i => i.PlaylistId == playlist.Id && trackIds.Contains(i.TrackId));

        // TODO:
        // ((ObservableList<TrackInfo>)playlist.Tracks).RemoveRange();
    }
        public static void Serialize(PlaylistInfo info)
        {
            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(PlaylistInfo));

            string dataPath = String.Format(Strings.libraryFormatPlaylists, PreferenceManager.GetLibraryLocation());

            FileStream dataFile = File.Create(dataPath + info.UUID + ".xml");

            serializer.Serialize(dataFile, info);
            dataFile.Close();
        }
Beispiel #11
0
        public void PlaylistInfoTest()
        {
            var playlist = new PlaylistInfo()
            {
                Name = "Duo"
            };

            builder.UpdatePlaylistInfo(playlist);

            builder.Build(replay);
            Assert.Equal(playlist.Name, replay.GameData.CurrentPlaylist);
        }
Beispiel #12
0
    /// <summary>
    /// プレイリストにトラック情報を追加する
    /// </summary>
    /// <param name="plyalist"></param>
    /// <param name="tracks"></param>
    public void Add(PlaylistInfo plyalist, ICollection <TrackInfo> tracks)
    {
        this._database.Context.PlaylistTracks.InsertBulk(tracks.Select(t => new PlaylistTrackDataModel
        {
            PlaylistId = plyalist.Id,
            TrackId    = t.Id,
            CreatedAt  = DateTimeOffset.Now,
        }));

        plyalist.Playlist.Tracks.AddRange(
            tracks.Select(t => new PlaylistTrackInfo(plyalist, t)));
    }
Beispiel #13
0
        /// <inheritdoc />
        public async ValueTask <SearchResponse> SearchAsync(string query)
        {
            var response = SearchResponse.Create(query);

            query = query switch
            {
                var trackUrl when _trackUrlRegex.IsMatch(query) => trackUrl,
                var albumUrl when _albumUrlRegex.IsMatch(query) => albumUrl,
                _ =>
                $"https://bandcamp.com/search?q={WebUtility.UrlEncode(query)}"
            };

            var json = await BandCampParser.ScrapeJsonAsync(_restClient, query)
                       .ConfigureAwait(false);

            if (string.IsNullOrWhiteSpace(json))
            {
                return(response.WithStatus(SearchStatus.SearchError));
            }

            try
            {
                var bcResult = JsonSerializer.Deserialize <BandCampResult>(json);
                response.WithStatus(bcResult.ItemType switch
                {
                    "album" => SearchStatus.PlaylistLoaded,
                    "track" => SearchStatus.TrackLoaded,
                    _ => SearchStatus.NoMatches
                });

                if (response.Status == SearchStatus.NoMatches)
                {
                    return(response);
                }

                long duration = 0;
                foreach (var trackInfo in bcResult.TrackInfo)
                {
                    var track = trackInfo.AsTrackInfo(bcResult.Artist, bcResult.Url, bcResult.ArtId);
                    response.WithTrack(track);
                    duration += track.Duration;
                }

                var playlistInfo = new PlaylistInfo()
                                   .WithId($"{bcResult.Current.Id}")
                                   .WithName(bcResult.Current.Title)
                                   .WithUrl(bcResult.Url)
                                   .WithDuration(duration)
                                   .WithArtwork(bcResult.ArtId == 0 ? default : $"https://f4.bcbits.com/img/a{bcResult.ArtId}_0.jpg");

                response.WithPlaylist(playlistInfo);
            }
        public static PlaylistInfo Deserialize(string filename, bool nullPlaylistHack)
        {
            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(PlaylistInfo));

            string dataPath = String.Format(Strings.libraryFormatPlaylists, PreferenceManager.GetLibraryLocation());

            FileStream   dataFile    = File.Open(filename, FileMode.Open);
            PlaylistInfo currentInfo = (PlaylistInfo)serializer.Deserialize(dataFile);

            dataFile.Close();

            return(currentInfo);
        }
Beispiel #15
0
        public void AddTracksToPlaylist(PlaylistInfo playlist, IEnumerable <Track> songsToAdd)
        {
            try
            {
                if (!HasAuthorizationAccess())
                {
                    if (!GetAuthorization())
                    {
                        Console.WriteLine("Unable to acquire authorization/access to the Spotify API.");
                        return;  //TODO:  Handle proper return codes.
                    }
                }

                using (WebClient wc = new WebClient())
                {
                    wc.Proxy = null;
                    wc.Headers.Add("Authorization", AccessToken.TokenType + " " + AccessToken.TokenCode);

                    NameValueCollection values = new NameValueCollection
                    {
                        { "client_id", Credentials.SoundAtlasClientID },
                        { "client_secret", Credentials.SoundAtlasClientSecret }
                    };

                    JObject body = new JObject
                    {
                        { "uris", JArray.FromObject(songsToAdd.Select(song => song.Uri)) }
                    };
                    String bodyString = body.ToString();

                    byte[] data;

                    try
                    {
                        String getPlaylistTracksURL = Endpoints.GetPlaylistTracks(playlist.UserInfo.Id, playlist.ID);
                        wc.UploadData(getPlaylistTracksURL, "POST", Encoding.UTF8.GetBytes(bodyString));
                    }
                    catch (WebException e)
                    {
                        using (StreamReader reader = new StreamReader(e.Response.GetResponseStream()))
                        {
                            data = Encoding.UTF8.GetBytes(reader.ReadToEnd());
                        }
                    }
                }
            }
            catch (WebException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #16
0
        public static void IsSet(this Assert assert, PlaylistInfo playlistInfo)
        {
            Assert.IsNotNull(playlistInfo);

            Assert.That.IsNotBlank(playlistInfo.Id);
            Assert.That.IsNotBlank(playlistInfo.Title);
            Assert.IsNotNull(playlistInfo.Author);
            Assert.IsNotNull(playlistInfo.Description);
            Assert.IsNotNull(playlistInfo.Videos);

            foreach (var video in playlistInfo.Videos)
            {
                Assert.That.IsSet(video);
            }
        }
        private PlaylistInfo buildTree()
        {
            PlaylistInfo current = new PlaylistInfo();

            current.FolderID = ulong.MaxValue; //root

            for (int i = 0; i < libspotify.sp_playlistcontainer_num_playlists(_containerPtr); i++)
            {
                PlaylistInfo playlist = new PlaylistInfo()
                {
                    PlaylistType = libspotify.sp_playlistcontainer_playlist_type(_containerPtr, i),
                    ContainerPtr = _containerPtr
                };

                switch (playlist.PlaylistType)
                {
                case libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_START_FOLDER:

                    playlist.FolderID = libspotify.sp_playlistcontainer_playlist_folder_id(_containerPtr, i);
                    playlist.Name     = getFolderName(_containerPtr, i);
                    playlist.Parent   = current;
                    current.Children.Add(playlist);
                    current = playlist;

                    break;

                case libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_END_FOLDER:

                    current = current.Parent;
                    break;

                case libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_PLAYLIST:

                    playlist.Pointer = libspotify.sp_playlistcontainer_playlist(_containerPtr, i);
                    playlist.Parent  = current;
                    current.Children.Add(playlist);

                    break;
                }
            }

            while (current.Parent != null)
            {
                current = current.Parent;
            }

            return(current);
        }
Beispiel #18
0
        public Playlist CreatePlaylist(String playlistName, String userId)
        {
            String createPlaylistURL = Endpoints.CreatePlaylist(userId);

            JObject body = new JObject
            {
                { "name", playlistName },
                { "public", "false" },  //Assume private playlists.
            };

            String       requestBody  = body.ToString();
            PlaylistInfo playlistInfo = PostRequest <PlaylistInfo>(createPlaylistURL, requestBody, true);
            Playlist     newPlaylist  = new Playlist(playlistInfo);

            return(newPlaylist);
        }
                    1463u)] // replay 6.30
        public void PlaylistInfoTest1(byte[] rawData, int bitCount,
                                      NetworkVersionHistory networkVersion, EngineNetworkVersionHistory engineNetworkVersion, uint id)
        {
            var reader = new NetBitReader(rawData, bitCount)
            {
                NetworkVersion       = networkVersion,
                EngineNetworkVersion = engineNetworkVersion
            };
            var playlist = new PlaylistInfo();

            playlist.Serialize(reader);

            Assert.Equal(id, playlist.Id);
            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
Beispiel #20
0
        /// <summary>
        /// Function:Set current play list info:time slice group current play message adapter name
        /// Author:Jerry Xu
        /// Date:2008-7-17
        /// </summary>
        /// <param name="playlist">PlaylistInfo:ref</param>
        /// <param name="flag">bool</param>
        public static void SetPlaylistTimeSlieceGroupCurrentMessageAdapterName(PlaylistInfo playlist, bool flag)
        {
            if (playlist == null || playlist.Items.Length == 0)
            {
                return;
            }
            int count = playlist.Items.Length;

            for (int i = 0; i < count; i++)
            {
                if (playlist.Items[i].Type == LibraryType.TimeSliceGroupProxy)
                {
                    ((TimeSliceGroupAdapterInfo)(playlist.Items[i])).CurrentMessageAdapterName = SetCurrentPlayMessageAdapterName((TimeSliceGroupAdapterInfo)(playlist.Items[i]), flag);
                }
            }
        }
Beispiel #21
0
        /// <summary>
        /// 获取播放列表
        /// </summary>
        private bool DownloadPlaylist(ref PlaylistInfo model)
        {
            while (true)
            {
                //获取今天的播放列表
                model = null;

                try
                {
                    List <AMS_Advertisement> advert = SeatManage.Bll.AdvertisementOperation.GetAdList(false, SeatManage.EnumType.AdType.PlaylistAd);
                    if (advert.Count < 1)
                    {
                        PlayListHandleEvent(this, "没有有效的播放列表");
                        return(false);
                    }
                    model    = PlaylistInfo.ToModel(advert[0].AdContent);
                    model.ID = advert[0].ID;
                    timer1.Stop();
                    timer1.Dispose();
                    return(true);
                }
                catch (Exception ex)
                {
                    PlayListHandleEvent(this, "服务器连接失败,正在重试……");
                    System.Threading.Thread.Sleep(2000);
                    if (s > 300)
                    {
                        timer1.Stop();
                        timer1.Dispose();
                        return(false);
                    }
                }

                //if (model != null)
                //{
                //    timer1.Stop();
                //    timer1.Dispose();
                //    return true;
                //}
                //else
                //{
                //    SeatManage.SeatManageComm.WriteLog.Write(ex.Message);
                //    return false;
                //}
            }
        }
        public List <PlaylistInfo> GetChildren(PlaylistInfo info)
        {
            if (!GetSessionContainer().IsLoaded)
            {
                throw new InvalidOperationException("Container is not loaded.");
            }

            PlaylistInfo tree = buildTree();

            if (info == null)
            {
                return(tree.Children);
            }
            else
            {
                return(searchTreeRecursive(tree, info).Children);
            }
        }
Beispiel #23
0
        public PlaylistInfo FindContainer(ulong folderID)
        {
            if (!GetSessionContainer().IsLoaded)
            {
                throw new InvalidOperationException("Session container is not loaded.");
            }

            PlaylistInfo tree = buildTree();

            if (folderID == 0)
            {
                return(tree);
            }
            else
            {
                return(searchTreeRecursive(tree, folderID));
            }
        }
Beispiel #24
0
        private void SerializingPlaylist(PlaylistInfo playlist)
        {
            if (playlist == null || playlist.Items == null || playlist.Items.Length == 0)
            {
                return;
            }

            if (!string.IsNullOrEmpty(playlist.ImagePath) &&
                File.Exists(playlist.ImagePath))
            {
                NailImageFileItem nailItem = new NailImageFileItem();
                nailItem            = new NailImageFileItem();
                nailItem.MemoryName = playlist.Name;
                nailItem.Type       = playlist.Type;
                nailItem.Content    = IOHelper.ReadAllBytes(playlist.ImagePath);
                nailItem.Name       = Path.GetFileName(playlist.ImagePath);
                _nailItems.Add(nailItem);
            }
        }
Beispiel #25
0
 public static List <YouTubeWebTrackResult> GetPlaylistTracks(PlaylistInfo playlist)
 {
     if (playlist?.items != null && playlist.items.Count > 0)
     {
         return(playlist.items.Select(x => new YouTubeWebTrackResult
         {
             Duration = TimeSpan.Zero,
             Title = x.snippet.title,
             Uploader = x.snippet.channelTitle,
             Result = x,
             Year = (uint)DateTime.Parse(x.snippet.publishedAt).Year,
             ImageUrl = [email protected],
             Views = 0,
             Url = $"https://www.youtube.com/watch?v={x.contentDetails.videoId}",
             Description = x.snippet.description
         }).ToList());
     }
     return(null);
 }
Beispiel #26
0
        private void SetTargetPlaylist(LibraryAdapter adapter)
        {
            if (adapter == null || _playlists == null || _playlists.Count == 0)
            {
                return;
            }

            adapter.Target = _playlists.Find(p => { return(p.Id == adapter.TargetId); });

            if (adapter.Target == null)
            {
                return;
            }

            PlaylistInfo playlist = adapter.Target as PlaylistInfo;

            if (playlist == null || playlist.Items == null || playlist.Items.Length == 0)
            {
                return;
            }

            playlist.Items.ForEach(p =>
            {
                switch (p.Type)
                {
                case LibraryType.MessageProxy:
                    SetTargetMessage(p);
                    break;

                case LibraryType.TimeSliceGroupProxy:
                    SetTargetTimeSliceGroup(p);
                    break;

                case LibraryType.PlaylistProxy:
                    SetTargetPlaylist(p);
                    break;
                }
            }
                                   );
        }
Beispiel #27
0
        public static PlaylistInfo PlaylistInfoFromJson(string rawJson)
        {
            if (rawJson.IsBlank())
            {
                throw new ArgumentNullException(nameof(rawJson));
            }

            // Get video ids
            var videoIdMatches = Regex.Matches(rawJson, @"""video_id""\s*:\s*""(.*?)""").Cast <Match>();
            var videoIds       = videoIdMatches
                                 .Select(m => m.Groups[1].Value)
                                 .Where(m => m.IsNotBlank())
                                 .Distinct()
                                 .ToArray();

            // Populate
            var result = new PlaylistInfo();

            result.VideoIds = videoIds;

            return(result);
        }
Beispiel #28
0
    /// <summary>
    /// プレイリストを作成する
    /// </summary>
    /// <param name="tracks"></param>
    /// <param name="name"></param>
    public PlaylistInfo Create(string name, ICollection <TrackInfo> tracks = null)
    {
        // プレイリストを登録して新規IDを発行する
        var newId = this._database.Context.Playlists.Insert(new PlaylistDataModel
        {
            Name      = name,
            CreatedAt = DateTimeOffset.Now,
            UpdatedAt = DateTimeOffset.Now,
        }).AsInt32;

        // プレイリストにトラック情報を紐付けする
        var playlist = new PlaylistInfo(newId, name);

        if (tracks is not null && tracks.Count > 0)
        {
            this.Add(playlist, tracks);
        }

        this.Playlists.Add(playlist);
        this.Registered?.Invoke(this, playlist);

        return(playlist);
    }
        private void ImportPlaylist(List <FileItem> images, List <FileItem> videos, List <MessageInfo> messages, List <TimeSliceGroupInfo> timesliceGroups, List <PlaylistInfo> playlists, PlaylistInfo playlistInfo)
        {
            if ((images == null || images.Count == 0) && (videos == null || videos.Count == 0) && (messages == null || messages.Count == 0) && (timesliceGroups == null || timesliceGroups.Count == 0) && (playlists == null || playlists.Count == 0) && playlistInfo == null)
            {
                return;
            }
            List <MessageFileItem>    listFiles           = new List <MessageFileItem>();
            List <MessageItem>        listMessages        = new List <MessageItem>();
            List <TimeSliceGroupItem> listTimeSliceGroups = new List <TimeSliceGroupItem>();
            List <PlaylistItem>       listPlaylists       = new List <PlaylistItem>();

            PlaylistInfo playlist     = null;
            PlaylistItem playlistItem = null;
            bool         isValid      = false;
            //if (images != null && images.Count > 0)
            //{

            MessageFileItem messageFile = null;

            AddFiles(images, listFiles);
            AddFiles(videos, listFiles);
            AddMessages(messages, listMessages);
            AddTimeSliceGroups(timesliceGroups, listTimeSliceGroups);
            AddPlaylists(playlists, listPlaylists);

            playlist             = LibraryGroup.Current.Playlists.GetByName(playlistInfo.Name);
            playlistItem         = new PlaylistItem();
            playlistItem.Item    = playlistInfo.Copy() as PlaylistInfo;
            playlistItem.IsValid = false;
            if (playlist == null)
            {
                playlistItem.IsValid = true;
            }
            //Batch load file :rename file and message
            ImportPlaylistRename(listFiles, listMessages, listTimeSliceGroups, listPlaylists, playlistItem);
            //}
        }
        public List<PlaylistInfo> GetChildren(PlaylistInfo info)
        {
            if (!IsLoaded)
                throw new InvalidOperationException("Container is not loaded.");

            PlaylistInfo tree = buildTree();

            if (info == null) {

                return tree.Children;

            } else {

                return searchTreeRecursive(tree, info).Children;

            }
        }
        private PlaylistInfo buildTree()
        {
            PlaylistInfo current = new PlaylistInfo();
            current.FolderID = ulong.MaxValue; //root

            for (int i = 0; i < libspotify.sp_playlistcontainer_num_playlists(_containerPtr); i++) {

                PlaylistInfo playlist = new PlaylistInfo() {
                    PlaylistType = libspotify.sp_playlistcontainer_playlist_type(_containerPtr, i),
                    ContainerPtr = _containerPtr
                };

                switch (playlist.PlaylistType) {

                    case libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_START_FOLDER:

                        playlist.FolderID = libspotify.sp_playlistcontainer_playlist_folder_id(_containerPtr, i);
                        playlist.Name = getFolderName(_containerPtr, i);
                        playlist.Parent = current;
                        current.Children.Add(playlist);
                        current = playlist;

                        break;

                    case libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_END_FOLDER:

                        current = current.Parent;
                        break;

                    case libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_PLAYLIST:

                        playlist.Pointer = libspotify.sp_playlistcontainer_playlist(_containerPtr, i);
                        playlist.Parent = current;
                        current.Children.Add(playlist);

                        break;

                }

            }

            while (current.Parent != null) {

                current = current.Parent;

            }

            return current;
        }
        private PlaylistInfo searchTreeRecursive(PlaylistInfo tree, PlaylistInfo find)
        {
            if (tree.FolderID == find.FolderID)
                return tree;

            foreach (PlaylistInfo playlist in tree.Children) {

                if (playlist.PlaylistType == libspotify.sp_playlist_type.SP_PLAYLIST_TYPE_START_FOLDER) {

                    if (playlist.FolderID == find.FolderID)
                        return playlist;

                    PlaylistInfo p2 = searchTreeRecursive(playlist, find);

                    if (p2 != null)
                        return p2;

                }

            }

            return null;
        }
 public void UpdatePlaylistInfo(PlaylistInfo playlist)
 {
     GameData.CurrentPlaylist ??= playlist.Name;
 }