Esempio n. 1
0
        public Collection <ApiAudioGenre> GetGenres()
        {
            var genres = new Collection <ApiAudioGenre>();

            var properties = new JsonArray(new[] { "title", "thumbnail" });
            var param      = new JsonObject();

            param["properties"] = properties;
            var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetGenres", param);

            if (result != null)
            {
                if (result.Contains("genres"))
                {
                    foreach (JsonObject genre in (JsonArray)result["genres"])
                    {
                        try
                        {
                            var gen = new ApiAudioGenre
                            {
                                IdGenre    = (long)(JsonNumber)genre["genreid"],
                                Name       = genre["title"].ToString(),
                                AlbumCount = 0,
                                Thumb      = genre["thumbnail"].ToString()
                            };
                            genres.Add(gen);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            return(genres);
        }
Esempio n. 2
0
        public Collection <ApiAudioGenre> GetGenres()
        {
            var genres = new Collection <ApiAudioGenre>();

            if (!_parent.IsConnected())
            {
                return(genres);
            }
            var dblines = _parent.IPimpDBCommand(new CommandInfoIPimp {
                Action = "getallmusicgenres"
            }, "genres");

            if (dblines == null)
            {
                return(genres);
            }

            foreach (JsonObject dbline in dblines)
            {
                var genre = new ApiAudioGenre
                {
                    Thumb      = (string)dbline["thumb"],
                    Fanart     = (string)dbline["fanart"],
                    Name       = (string)dbline["genre"],
                    AlbumCount = Convert.ToInt32("0" + (string)dbline["numalbums"], CultureInfo.InvariantCulture),
                    IdGenre    = Convert.ToInt32("0" + (string)dbline["id"], CultureInfo.InvariantCulture)
                };

                genres.Add(genre);
            }

            return(genres);
        }
Esempio n. 3
0
 public Yatse2AudioGenre(ApiAudioGenre apiAudioGenre)
 {
     if (apiAudioGenre == null)
     {
         return;
     }
     IdGenre    = apiAudioGenre.IdGenre;
     Name       = apiAudioGenre.Name;
     AlbumCount = apiAudioGenre.AlbumCount;
     Thumb      = apiAudioGenre.Thumb;
     Fanart     = apiAudioGenre.Fanart;
 }
Esempio n. 4
0
        public ApiAudioGenre ToApi()
        {
            var api = new ApiAudioGenre
            {
                Fanart     = Fanart,
                AlbumCount = AlbumCount,
                IdGenre    = IdGenre,
                Name       = Name,
                Thumb      = Thumb
            };

            return(api);
        }
Esempio n. 5
0
        public Collection <ApiAudioGenre> GetGenres()
        {
            _parent.Trace("JRiver Get Genres Running");
            var genres = new Collection <ApiAudioGenre>();

            return(genres);


            try
            {
                getallItems("/MCWS/v1/Files/Search?Action=mpl&ActiveFile=-1&Zone=-1&ZoneType=ID&Query=[Media%20Type]=[Audio]");
                foreach (var Field in Allitems)
                {
                    string result = "";
                    if (Field.TryGetValue("Genre", out result))
                    {
                        if (result != "" && result != null)
                        {
                            //Only take Genre from those entries that have Album Name -

                            string GenreName = Field.ValueOrDefault("Genre");

                            if (GenreName != "" && GenreName != null)
                            {
                                var gen = new ApiAudioGenre
                                {
                                    IdGenre    = (long)Xbmc.IDstringtoNumber(GenreName),
                                    Name       = GenreName.ToString(),
                                    AlbumCount = 0,
                                    Thumb      = ""
                                };

                                if (!genres.Any(a => a.Name == GenreName))  //check Genre doesnt already exisit
                                {
                                    genres.Add(gen);
                                }
                            }
                        }
                    }
                }

                return(genres);
            }
            catch (Exception ex)
            {
                _parent.Trace("JRiver GetGenre:" + ex);
                return(genres);
            }
        }
Esempio n. 6
0
        public Collection <ApiAudioGenre> GetGenres()
        {
            var genres  = new Collection <ApiAudioGenre>();
            var dblines = _parent.DBCommand("music", "SELECT idGenre,strGenre,COUNT(DISTINCT strAlbum) AS albumCount FROM albumview GROUP BY idGenre");

            if (dblines == null)
            {
                return(genres);
            }
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 3)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var genre = new ApiAudioGenre {
                    IdGenre = Xbmc.StringToNumber(dbline[0]), Name = dbline[1], AlbumCount = Xbmc.StringToNumber(dbline[2])
                };
                genres.Add(genre);
            }
            return(genres);
        }
Esempio n. 7
0
        public Collection <ApiAudioGenre> GetGenres()
        {
            var MusicID = GetMainSelection("Genres");  //Genres bit no longer needed
            // Change away from GetMainSelection which is no longer working
            // Use Emby Genres to get info.

            var genres = new Collection <ApiAudioGenre>();

            try
            {
                _parent.Trace("Getting Music Genres: Parent IP: " + _parent.IP);
                string NPurl   = "http://" + _parent.IP + ":" + _parent.Port + "/MusicGenres?ParentId=" + MusicID;
                var    request = WebRequest.CreateHttp(NPurl);
                request.Method  = "get";
                request.Timeout = 150000;
                _parent.Trace("Genre Music Selection: " + NPurl);
                var authString = _parent.GetAuthString();
                request.Headers.Add("X-MediaBrowser-Token", Globals.EmbyAuthToken);
                request.Headers.Add("X-Emby-Authorization", authString);
                request.ContentType = "application/json; charset=utf-8";
                request.Accept      = "application/json; charset=utf-8";

                var response = request.GetResponse();

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)
                {
                    System.IO.Stream dataStream = response.GetResponseStream();
//REMOTETHIS        System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);

                    using (var sr = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        string json = sr.ReadToEnd();
                        _parent.Trace("--------------GETTING Music Genres Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();
                        var ItemData     = deserializer.Deserialize <MusicGenres.Rootobject>(json);
                        _parent.Trace("---------------Get Music Genres:  Issue: Results.Record Count: " + ItemData.TotalRecordCount);

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {
                                var gen = new ApiAudioGenre
                                {
                                    IdGenre    = Xbmc.IDtoNumber(genre.Id),
                                    Name       = genre.Name ?? "",
                                    AlbumCount = 0, //genre.ChildCount,
                                    Thumb      = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? ""
                                };
                                genres.Add(gen);
                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("Music Genres Exception Caught " + ex);
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another Music Genres exception" + Ex);
            }


            return(genres);
        }