public List <WebPlaylist> GetWebPlaylist()
        {
            var webPlaylists    = new List <WebPlaylist>();
            SQLiteConnection db = null;

            try
            {
                db = ConnectDb();

                string           sql     = "select * from web_playlist";
                SQLiteCommand    command = new SQLiteCommand(sql, db);
                SQLiteDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    var webPlaylist = new WebPlaylist(reader["pid"].ToString(), reader["playlist"].ToString());
                    webPlaylists.Add(webPlaylist);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
            return(webPlaylists);
        }
Example #2
0
        private WebPlaylist GetPlaylist(string path)
        {
            PlayList    mpPlaylist = new PlayList();
            IPlayListIO factory    = PlayListFactory.CreateIO(path);

            if (factory.Load(mpPlaylist, path))
            {
                WebPlaylist webPlaylist = new WebPlaylist()
                {
                    Id = EncodeTo64(Path.GetFileName(path)), Title = mpPlaylist.Name, Path = new List <string>()
                    {
                        path
                    }
                };
                webPlaylist.ItemCount = mpPlaylist.Count;
                return(webPlaylist);
            }
            else
            {
                Log.Warn("Couldn't parse playlist " + path);
                return(null);
            }
        }
Example #3
0
        public static Task <IList <WebPlaylist> > ProcessAsync(IOwinContext context)
        {
            ICollection <PlaylistInformationData> playlists = ServiceRegistration.Get <IMediaLibrary>().GetPlaylists();

            List <WebPlaylist> output = new List <WebPlaylist>();

            foreach (var playlist in playlists)
            {
                WebPlaylist webPlaylist = new WebPlaylist
                {
                    ItemCount = playlist.NumItems,
                    Type      = WebMediaType.Playlist,
                    Id        = playlist.PlaylistId.ToString(),
                    Title     = playlist.Name
                };
                //webPlaylist.Artwork;
                //webPlaylist.DateAdded;
                //webPlaylist.Path;

                output.Add(webPlaylist);
            }

            return(Task.FromResult <IList <WebPlaylist> >(output));
        }