Пример #1
0
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            if (parameters.TryGetValue("id", out string seriesId))
            {
                _seriesDetails = await _seriesProvider.GetSeriesVideosAsync(seriesId);

                Series = new UserSeriesItemViewModel(_seriesDetails);
                User   = new NicoVideoOwner()
                {
                    OwnerId    = _seriesDetails.Owner.Id,
                    UserType   = _seriesDetails.Owner.OwnerType,
                    ScreenName = _seriesDetails.Owner.Nickname,
                    IconUrl    = _seriesDetails.Owner.IconUrl,
                };

                SeriesVideoPlaylist = new SeriesVideoPlaylist(new PlaylistId()
                {
                    Id = seriesId, Origin = PlaylistItemsSourceOrigin.Series
                }, _seriesDetails);
                SelectedSortOption = SeriesVideoPlaylist.DefaultSortOption;

                this.ObserveProperty(x => x.SelectedSortOption).Subscribe(_ =>
                {
                    ResetList();
                })
                .AddTo(_navigationDisposables);
            }

            await base.OnNavigatedToAsync(parameters);
        }
Пример #2
0
        public void GetFullSeriesByIdTestSuccessfullWithLanguage()
        {
            WebInterface         target     = new WebInterface(apiKey);
            Task <SeriesDetails> taskResult = target.GetFullSeriesById(83462, "de", this.testMirror);
            SeriesDetails        result     = taskResult.Result;


            Assert.Equal("de", result.Language);


            Episode firstEpisode = result.Series.Episodes.First(x => x.SeasonNumber == 1 && x.Number == 1);

            // check series
            Assert.NotNull(result);
            Assert.Equal(83462, result.Series.Id);
            Assert.Equal("Castle", result.Series.Name);
            Assert.Equal("de", result.Series.Language);

            // check episodes
            Assert.Equal(1, firstEpisode.SeasonNumber);
            Assert.Equal(1, firstEpisode.Number);
            Assert.Equal(398671, firstEpisode.Id);
            Assert.Equal("Blumen für Dein Grab", firstEpisode.Name);

            result.Dispose();
        }
Пример #3
0
        public void GetFullSeriesByIdTestSuccessfullWithDefaultLanguage()
        {
            WebInterface         target     = new WebInterface(apiKey);
            Task <SeriesDetails> taskResult = target.GetFullSeriesById(83462, this.testMirror);
            SeriesDetails        result     = taskResult.Result;
            Episode firstEpisode            = result.Series.Episodes.First(x => x.SeasonNumber == 1 && x.Number == 1);

            // check details
            Assert.Equal("en", result.Language);

            Assert.NotNull(result.Actors);
            Assert.Equal(9, result.Actors.Count);

            Assert.NotNull(result.Banners);
            Assert.True(result.Banners.Count > 10);

            // check series
            Assert.NotNull(result);
            Assert.Equal(83462, result.Series.Id);
            Assert.Equal("Castle (2009)", result.Series.Name);
            Assert.Equal("en", result.Series.Language);

            // check episodes
            Assert.Equal(1, firstEpisode.SeasonNumber);
            Assert.Equal(1, firstEpisode.Number);
            Assert.Equal(398671, firstEpisode.Id);
            Assert.Equal("Flowers for Your Grave", firstEpisode.Name);

            result.Dispose();
        }
        private void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Series s = (Series)e.ClickedItem;

            this.selectedSeriesDetails    = s.getSeriesDetails();
            this.DisplayPoster.Source     = s.poster;
            this.DetailsColumn.Visibility = Visibility.Visible;
        }
Пример #5
0
        public void CosntructorTestSuccessfull()
        {
            SeriesDetails target = new SeriesDetails(this.testExtractionPath, "en");

            Assert.Equal("en", target.Language);
            Assert.NotNull(target.Actors);
            Assert.NotNull(target.Banners);
            Assert.NotNull(target.Series);
        }
Пример #6
0
        public void DeserializeBannersTest()
        {
            SeriesDetails target     = new SeriesDetails(this.testExtractionPath, "en");
            Type          targetType = typeof(SeriesDetails);
            var           method     = targetType.GetMethod("DeserializeBanners", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            method.Invoke(target, new object[0]);

            Assert.NotNull(target.Banners);
            Assert.Equal(125, target.Banners.Count);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            SeriesDetails s = (SeriesDetails)e.Parameter;

            this.selectedSeries           = s.getSeries();
            AnimeTitle.Text               = s.getTitle();
            AnimePoster.Source            = s.poster;
            DetailsBackground.ImageSource = s.panel;
            EpisodeList.ItemsSource       = new List <Episode>(s.getEpisodes());
            SetWatchStatusPanel(s.seriesWatchState);
        }
Пример #8
0
        public void DeserializeSeriesTest()
        {
            SeriesDetails target     = new SeriesDetails(this.testExtractionPath, "en");
            Type          targetType = typeof(SeriesDetails);
            var           method     = targetType.GetMethod("DeserializeSeries", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            method.Invoke(target, new object[0]);

            Assert.NotNull(target.Series);
            Assert.Equal(83462, target.Series.Id);
            Assert.Equal("Castle (2009)", target.Series.Name);
            Assert.Equal(121, target.Series.Episodes.Count);
        }
Пример #9
0
        /// <summary>
        /// Gets all details of the series.
        /// </summary>
        /// <param name="id">Id of the series.</param>
        /// <param name="languageAbbreviation">The language abbreviation.</param>
        /// <param name="mirror">The mirror to use.</param>
        /// <returns>All details of the series.</returns>
        /// <example>Shows how the get all details of a series by its id.
        /// <code>
        /// namespace Docunamespace
        /// {
        ///     /// <summary>
        ///     /// Class for the docu.
        ///     /// </summary>
        ///     class DocuClass
        ///     {
        ///         /// <summary>
        ///         /// Gets all details of a series.
        ///         /// </summary>
        ///         public SeriesDetails GetSeries(int id, Mirror mirror, Language language)
        ///         {
        ///				string apiKey = "ABCD12345";
        ///             TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
        ///             SeriesDetails details = await instance.GetFullSeriesById(id, language.Abbreviation, mirror);
        ///
        ///             return details;
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        public async Task <SeriesDetails> GetFullSeriesById(int id, string languageAbbreviation, Mirror mirror)
        {
            if (id == 0)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(languageAbbreviation))
            {
                return(null);
            }

            if (mirror == null)
            {
                return(null);
            }

            string url = "{0}/api/{1}/series/{2}/all/{3}.zip";

            byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, this.APIKey, id, languageAbbreviation)).ConfigureAwait(continueOnCapturedContext: false);

            // store the zip file.
            using (FileStream zipFile = new FileStream(this.loadedSeriesPath, FileMode.Create, FileAccess.Write))
            {
                zipFile.Write(result, 0, (int)result.Length);
                zipFile.Flush();
                zipFile.Close();
            }

            DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(FileDirectory, "extraction"));

            if (!dirInfo.Exists)
            {
                dirInfo.Create();
            }


            // extract the file.
            using (ZipArchive archive = ZipFile.OpenRead(this.loadedSeriesPath))
            {
                foreach (ZipArchiveEntry entry in archive.Entries)
                {
                    entry.ExtractToFile(Path.Combine(dirInfo.FullName, entry.Name), true);
                }
            }

            SeriesDetails details = new SeriesDetails(dirInfo.FullName, languageAbbreviation);

            return(details);
        }
Пример #10
0
        private async void LoadData(string link, SeriesDetails showData = default)
        {
            loadingView.Visibility = ViewStates.Visible;
            ShowData = showData is null ? await WebData.GetDetailsForTVShowSeries(link) : showData;

            loadingView.Visibility = ViewStates.Gone;
            if (ShowData != null)
            {
                if (await StorageData.IsMarkedFavorite(ShowData))
                {
                    isFavorite = true;
                }
                InvalidateOptionsMenu();
                collapseToolbar.TitleEnabled = false;
                SupportActionBar.SetDisplayShowTitleEnabled(false);
                Picasso.With(this).Load(ShowData.ImageLink).Into(detailImage);
                collapseToolbar.Title = titleText.Text = ShowData.Title;
                descriptionText.Text  = "Description: " + ShowData.Description;
                releaseText.Text      = "Released: " + ShowData.ReleaseDate;
                genreText.Text        = ShowData.Genres;

                seasonsHeader.Visibility       = ViewStates.Visible;
                seasonEpisodesPager.Visibility = ViewStates.Visible;
                if (ShowData.Seasons != null && ShowData.Seasons.Count > 0)
                {
                    var adapter = new PageTabsAdapter(SupportFragmentManager);
                    foreach (var season in ShowData.Seasons)
                    {
                        adapter.AddTab(new TitleFragment()
                        {
                            Fragmnet = new MainTabs(DataEnum.DataType.SeasonsEpisodes, season.Episodes.Cast <object>()), Title = season.SeasonName
                        });
                    }
                    seasonsHeader.TabMode = ShowData.Seasons.Count < 5 ? TabLayout.ModeFixed : TabLayout.ModeScrollable;
                    seasonsHeader.SetupWithViewPager(seasonEpisodesPager);
                    seasonEpisodesPager.OffscreenPageLimit = ShowData.Seasons.Count;
                    seasonEpisodesPager.Adapter            = adapter;
                }
                else
                {
                    seasonEpisodesPager.Visibility = ViewStates.Gone;
                    seasonsHeader.Visibility       = ViewStates.Gone;
                    Error.Instance.ShowErrorSnack($"No episodes were found for {ShowData.Title}.", titleContainer);
                }
            }
            else
            {
                Error.Instance.ShowErrorSnack($"TV Show '{ShowData.Title}' could not be loaded.", titleContainer);
            }
        }
Пример #11
0
        public void DisposeTestSuccessfull()
        {
            SeriesDetails target = new SeriesDetails(this.testExtractionPath, "en");

            var dummyCall = target.Actors;

            dummyCall = null;

            target.Dispose();

            Assert.Equal(null, target.Language);
            Assert.Null(target.Actors);
            Assert.Null(target.Banners);
            Assert.Null(target.Series);
        }
Пример #12
0
 private void ListView_ItemClick(object sender, ItemClickEventArgs e)
 {
     Series s = (Series)e.ClickedItem;
     SeriesDetails sd = s.getSeriesDetails();
     Frame.Navigate(typeof(DetailsPage), sd);
 }
Пример #13
0
 public UserSeriesItemViewModel(SeriesDetails userSeries)
 {
     _userSeries = userSeries;
 }
Пример #14
0
		/// <summary>
		/// Gets all details of the series.
		/// </summary>
		/// <param name="id">Id of the series.</param>
		/// <param name="languageAbbreviation">The language abbreviation.</param>
		/// <param name="mirror">The mirror to use.</param>
		/// <returns>All details of the series.</returns>
		/// <example>Shows how the get all details of a series by its id.
		/// <code>
		/// namespace Docunamespace
		/// {
		/// 	/// <summary>
		/// 	/// Class for the docu.
		/// 	/// </summary>
		/// 	class DocuClass
		/// 	{
		/// 		/// <summary>
		/// 		/// Gets all details of a series.
		/// 		/// </summary>
		/// 		public SeriesDetails GetSeries(int id, Mirror mirror, Language language)
		/// 		{
		///				string apiKey = "ABCD12345";
		/// 			TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
		/// 			SeriesDetails details = await instance.GetFullSeriesById(id, language.Abbreviation, mirror);
		/// 
		/// 			return details;
		/// 		}
		/// 	}
		/// }
		/// </code>
		/// </example>
		public async Task<SeriesDetails> GetFullSeriesById(int id, string languageAbbreviation, Mirror mirror)
		{
			if (id == 0)
			{
				return null;
			}

			if (string.IsNullOrEmpty(languageAbbreviation))
			{
				return null;
			}

			if (mirror == null)
			{
				return null;
			}

			string url = "{0}/api/{1}/series/{2}/all/{3}.zip";
            byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, this.APIKey, id, languageAbbreviation)).ConfigureAwait(continueOnCapturedContext: false);

			// store the zip file.
			using (FileStream zipFile = new FileStream(this.loadedSeriesPath, FileMode.Create, FileAccess.Write))
			{
				zipFile.Write(result, 0, (int)result.Length);
				zipFile.Flush();
				zipFile.Close();
			}

		    DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(FileDirectory, "extraction"));
			if (!dirInfo.Exists)
			{
				dirInfo.Create();
			}


			// extract the file.
			using (ZipArchive archive = ZipFile.OpenRead(this.loadedSeriesPath))
			{
				foreach (ZipArchiveEntry entry in archive.Entries)
				{
					entry.ExtractToFile(Path.Combine(dirInfo.FullName, entry.Name), true);
				}
			}

			SeriesDetails details = new SeriesDetails(dirInfo.FullName, languageAbbreviation);

			return details;
		}