Exemple #1
0
        public Movie(String file, JsonMainDetails.Data infos, String coverFileName) : this()
        {
            TimeAdded = DateTime.Now.ToUnixTimestamp();

            Title = infos.title;
            try
            {
                Year = int.Parse(infos.year);
            }
            catch { }
            if (infos.plot != null)
            {
                Plot = infos.plot.outline;
            }
            ImdbId = infos.tconst;
            Principals.AddRange(infos.cast_summary.NoNull().Select(p => p.name.name));
            Directors.AddRange(infos.directors_summary.NoNull().Select(p => p.name.name));
            Writers.AddRange(infos.writers_summary.NoNull().Select(p => p.name.name));
            Genres.AddRange(infos.genres.NoNull());
            ImdbRating = infos.rating;
            if (infos.runtime != null)
            {
                Duration = infos.runtime.time;
            }

            Files.Add(file);
            Cover = coverFileName;
        }
Exemple #2
0
        public void BuildBasicInfo(string htmlDoc)
        {
            var s = CQ.Create(htmlDoc);

            Name = HttpUtility.HtmlDecode(s[".artist-name"]?.FirstOrDefault()?
                                          .InnerHTML?.Trim() ?? "Unkown Artist");

            Tagline = HttpUtility.HtmlDecode(s[".biography span"]?.FirstOrDefault()?
                                             .InnerHTML?.Trim() ?? string.Empty);

            string birth = s[".birth div"]?.FirstOrDefault()?.InnerHTML?.Trim() ?? "-1";

            if (birth.Length > 4)
            {
                birth = birth.SubstringFromLastIndex('1').Substring(0, 4);
            }

            Birth = birth.ToInt();

            Members = getRelatedArtists(s[".group-members a"]);

            Genres = s[".genre a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim())).ToList()
                     ?? new List <string>();

            Genres.AddRange(s[".styles a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim()))
                            ?? new List <string>());

            Moods = s[".moods a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim())).ToList()
                    ?? new List <string>();

            Themes = s[".themes a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim())).ToList()
                     ?? new List <string>();
        }
Exemple #3
0
        /// <summary>
        /// Populates the object with metadata from the taglib file object
        /// </summary>
        protected override void PopulateMediaMetadata()
        {
            if (!string.IsNullOrEmpty(Path))
            {
                // try to create the file object
                TagLib.File file = null;
                try
                {
                    file = TagLib.File.Create(Path);
                }
                catch { }

                // if the file obj was successfully created, get data from it
                if (file != null)
                {
                    Artists.AddRange(file.Tag.AlbumArtists);
                    Album = file.Tag.Album;
                    Genres.AddRange(file.Tag.Genres);
                    Composers.AddRange(file.Tag.Composers);

                    Title    = file.Tag.Title;
                    Year     = file.Tag.Year;
                    Track    = file.Tag.Track;
                    Disc     = file.Tag.Disc;
                    Duration = file.Properties.Duration;
                    Lyrics   = file.Tag.Lyrics;
                    Comment  = file.Tag.Comment;
                }
            }
        }
Exemple #4
0
        public void BuildBasicInfo(string htmlDoc)
        {
            var s = CQ.Create(htmlDoc);

            Title = HttpUtility.HtmlDecode(s["h1.album-title"]?.FirstOrDefault()?
                                           .InnerHTML?.Trim() ?? "Unknown Title");

            Artists = s[".album-artist a"]?.Select(z => new RelatedArtist(z)).ToList()
                      ?? new List <RelatedArtist>();

            ReleaseDate = s[".release-date span"]?.FirstOrDefault()?
                          .InnerHTML?.Reverse().Take(4).Reverse().Join().ToInt() ?? -1;

            Genres = s[".genre a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim())).ToList()
                     ?? new List <string>();

            Genres.AddRange(s[".styles a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim()))
                            ?? new List <string>());

            Moods = s[".moods a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim())).ToList()
                    ?? new List <string>();

            Themes = s[".themes a"]?.Select(x => HttpUtility.HtmlDecode(x.InnerHTML.Trim())).ToList()
                     ?? new List <string>();

            Tracks = new List <AlbumTrack>();
            var total_discs = s[".track-listing .disc"];

            for (var i = 0; i < total_discs.Count(); i++)
            {
                Tracks.AddRange(CQ.Create(total_discs[i])[".track"].Select(x => new AlbumTrack(x, i + 1)));
            }
        }
        async Task AddUpcomingMoviesAsync(int page)
        {
            IsBusy = true;

            try
            {
                if (!IsNotConnected)
                {
                    if (Genres.Count == 0)
                    {
                        Genres.AddRange(await _tmdbService.GetMovieGenresAsync(_tokenSource.Token));
                    }

                    // found no way to filter through query
                    var movies = await _tmdbService.GetUpcomingMoviesAsync(_tokenSource.Token, page);

                    if (!_tokenSource.IsCancellationRequested)
                    {
                        movies = movies.Where(x => !string.IsNullOrWhiteSpace(x.PosterPath) &&
                                              !string.IsNullOrWhiteSpace(x.BackdropPath)).ToList();
                        movies.ForEach(AddUpcomingMovie);

                        if (_loadMoreMovieIndex == 0)
                        {
                            _loadMoreMovieIndex = Movies.Count / 2;
                            _loadMoreMovie      = Movies[_loadMoreMovieIndex];
                        }
                        else
                        {
                            _loadMoreMovieIndex += movies.Count - 1;
                            _loadMoreMovie       = Movies[_loadMoreMovieIndex];
                        }

                        _lastLoadedMovie   = Movies.Last();
                        _hasLoadedLastPage = movies.Count == 0;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }

            IsBusy = false;
        }
        //----------------------------------- GENRES --------------------------------------------------------------

        public void GetGenres()
        {
            try
            {
                Genres.AddRange(LastFm.GetGenres());
                Genres.Remove(new Genre()
                {
                    Name = "hip hop"
                });
                Genres.Add(new Genre()
                {
                    Name = "grunge"
                });

                Genres.ForEach(g => g.Name    = g.Name.Replace("&", "And"));
                Genres.ForEach(g => g.SqlName = g.Name.Replace("'", "''").ToLower());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #7
0
 /// <summary>
 /// Add the specified genres and albums to this popultion.
 /// Update the SeedPopulation with the new genres so that they can be persisted
 /// </summary>
 /// <param name="genres"></param>
 /// <param name="albums"></param>
 public void Add(IEnumerable <string> genres, IEnumerable <Album> albums)
 {
     SeedPopulation.AddGenres(genres);
     Genres.AddRange(genres);
     Albums.AddRange(albums);
 }