Beispiel #1
0
        public void ResultPicked(Game result, string fullFolderPath)
        {
            if (result.Cover == null)
            {
                throw new Exception("NoPoster");
            }

            var folderName      = Path.GetFileName(fullFolderPath);
            var localPosterPath = fullFolderPath + @"\" + folderName + ".png";
            var year            = result.FirstReleaseDate != null?result.FirstReleaseDate.Value.Year.ToString() : "";

            var posterUrl = ImageHelper.GetImageUrl(result.Cover.Value.ImageId, ImageSize.HD720);

            Util.AddToPickedListDataTable(_listDataTable, localPosterPath, result.Name, "", fullFolderPath, folderName,
                                          year);
            var tempImage = new ImageToDownload
            {
                LocalPath  = localPosterPath,
                RemotePath = new Uri("https://" + posterUrl.Substring(2))
            };

            _imgDownloadList.Add(tempImage);
        }
Beispiel #2
0
    /// <summary>
    /// Prepares the Selected Result for Download And final List View
    /// </summary>
    /// <param name="result">Search Response</param>
    /// <param name="resultType">Type of search Response.</param>
    /// <param name="fullFolderPath">Full Path to the current Media Folder</param>
    /// <param name="rating">Rating for media</param>
    /// <param name="isPickedById"> identifies if Title was picked by media ID.</param>
    /// TODO: Merge parameter response and resultType.
    public void ResultPicked(dynamic result, string resultType, string fullFolderPath, string rating = "", bool isPickedById = false)
    {
        if (result.PosterPath == null)
        {
            throw new InvalidDataException("NoPoster");
        }

        var id   = 0;
        var type = resultType;

        if (string.IsNullOrWhiteSpace(rating) && resultType != MediaTypes.Collection)
        {
            rating = result.VoteAverage.ToString(CultureInfo.InvariantCulture);
        }

        var folderName      = Path.GetFileName(fullFolderPath);
        var localPosterPath = fullFolderPath + @"\" + folderName + ".png";

        string posterUrl = string.Concat(PosterBase, result.PosterPath.Replace("http://image.tmdb.org/t/p/w500", ""));

        if (resultType == MediaTypes.Tv)
        {
            dynamic pickedResult = isPickedById ? (TvShow)result : (SearchTv)result;
            var     year         = pickedResult.FirstAirDate != null?pickedResult.FirstAirDate.Year.ToString(CultureInfo.InvariantCulture) : "";

            Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name,
                                          rating, fullFolderPath, folderName,
                                          year);
            id = pickedResult.Id;
        }
        else if (resultType == MediaTypes.Movie)
        {
            dynamic pickedResult = isPickedById ? (Movie)result : (SearchMovie)result;
            var     year         = pickedResult.ReleaseDate != null?pickedResult.ReleaseDate.Year.ToString(CultureInfo.InvariantCulture) : "";

            Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title,
                                          rating, fullFolderPath, folderName, year);
            id = pickedResult.Id;
        }
        else if (resultType == MediaTypes.Collection)
        {
            dynamic pickedResult = isPickedById ? (Collection)result : (SearchCollection)result;
            Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, rating, fullFolderPath,
                                          folderName, "");
            id = pickedResult.Id;
        }
        else if (resultType == MediaTypes.Mtv)
        {
            MediaType mediaType = result.MediaType;
            switch (mediaType)
            {
            case MediaType.Tv:
            {
                type = "TV";
                dynamic pickedResult = isPickedById ? (TvShow)result : (SearchTv)result;
                var     year         = pickedResult.FirstAirDate != null
                        ? pickedResult.FirstAirDate.Year.ToString(CultureInfo.InvariantCulture)
                        : "";

                Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name,
                                              rating, fullFolderPath, folderName,
                                              year);
                id = pickedResult.Id;
                break;
            }

            case MediaType.Movie:
            {
                type = "Movie";
                dynamic pickedResult = isPickedById ? (Movie)result : (SearchMovie)result;
                var     year         = pickedResult.ReleaseDate != null
                        ? pickedResult.ReleaseDate.Year.ToString(CultureInfo.InvariantCulture)
                        : "";

                Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title,
                                              rating, fullFolderPath, folderName,
                                              year);
                id = pickedResult.Id;
                break;
            }
            }
        }

        if (!isPickedById && id != 0)
        {
            Util.SaveMediaInfo(id, type, fullFolderPath);
        }
        var tempImage = new ImageToDownload
        {
            LocalPath  = localPosterPath,
            RemotePath = new Uri(posterUrl)
        };

        _imgDownloadList.Add(tempImage);
    }
Beispiel #3
0
        /// <summary>
        /// Prepares the Selected Result for Download And final List View
        /// </summary>
        /// <param name="result">Search Response</param>
        /// <param name="resultType">Type of search Response.</param>
        /// <param name="fullFolderPath">Full Path to the current Media Folder</param>
        /// TODO: Merge parameter response and resultType.
        public void ResultPicked(dynamic result, string resultType, string fullFolderPath)
        {
            if (result.PosterPath == null)
            {
                throw new Exception("NoPoster");
            }

            var    folderName      = Path.GetFileName(fullFolderPath);
            var    localPosterPath = fullFolderPath + @"\" + folderName + ".png";
            string posterUrl       = string.Concat(PosterBase, result.PosterPath);

            if (resultType.Equals(MediaTypes.TV))
            {
                var pickedResult = (SearchTv)result;
                var year         = pickedResult.FirstAirDate != null?pickedResult.FirstAirDate.Value.Year.ToString() : "";

                Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name,
                                              pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName,
                                              year);
            }
            else if (resultType.Equals(MediaTypes.Movie))
            {
                var pickedResult = (SearchMovie)result;
                var year         = pickedResult.ReleaseDate != null?pickedResult.ReleaseDate.Value.Year.ToString() : "";

                Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title,
                                              pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, year);
            }
            else if (resultType.Equals(MediaTypes.Collection))
            {
                var searchResult = (SearchCollection)result;
                Util.AddToPickedListDataTable(_listDataTable, localPosterPath, searchResult.Name, "", fullFolderPath,
                                              folderName);
            }
            else if (resultType.Equals(MediaTypes.MTV))
            {
                MediaType mediaType = result.MediaType;
                switch (mediaType)
                {
                case MediaType.Tv:
                {
                    SearchTv pickedResult = result;
                    var      year         = pickedResult.FirstAirDate != null
                            ? pickedResult.FirstAirDate.Value.Year.ToString()
                            : "";

                    Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name,
                                                  pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName,
                                                  year);
                    break;
                }

                case MediaType.Movie:
                {
                    SearchMovie pickedResult = result;
                    var         year         = pickedResult.ReleaseDate != null
                            ? pickedResult.ReleaseDate.Value.Year.ToString()
                            : "";

                    Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title,
                                                  pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName,
                                                  year);
                    break;
                }
                }
            }

            var tempImage = new ImageToDownload
            {
                LocalPath  = localPosterPath,
                RemotePath = new Uri(posterUrl)
            };

            _imgDownloadList.Add(tempImage);
        }