Example #1
0
        private void AddSeasonButton_Click(object sender, RoutedEventArgs e)
        {
            Season season = new Season(PlexViewModel.SelectedShow.NumberSeasons);

            PlexViewModel.SelectedShow.AddSeason(season);
        }
Example #2
0
        private async void OpenShow_ClickAsync(object sender, RoutedEventArgs e)
        {
            FolderPicker picker = new FolderPicker
            {
                SuggestedStartLocation = PickerLocationId.Desktop
            };

            picker.FileTypeFilter.Add("*");

            StorageFolder folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                Show show = new Show(null, folder.Name, folder.Path);

                // add to list of places allowed
                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace(show.Id, folder);

                QueryOptions queryOptions = new QueryOptions(CommonFileQuery.OrderByName, VideoExtensions)
                {
                    FolderDepth = FolderDepth.Shallow
                };
                StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);

                IReadOnlyList <StorageFile> unsortedEpisodeFiles = await queryResult.GetFilesAsync();

                foreach (StorageFile unsortedEpisodeFile in unsortedEpisodeFiles)
                {
                    Episode episode = new Episode(-1, unsortedEpisodeFile.Path);
                    show.UnsortedSeason.AddEpisode(episode);
                }

                IReadOnlyList <StorageFolder> folders = await folder.GetFoldersAsync();

                foreach (StorageFolder seasonFolder in folders)
                {
                    Season season;

                    if (IsCorrectSeasonName(seasonFolder.Name))
                    {
                        season = new Season(GetSeasonNumberFromFolder(seasonFolder.Name), seasonFolder.Name);
                        show.AddSeason(season);
                    }
                    else
                    {
                        season = show.UnsortedSeason;
                    }

                    queryResult = seasonFolder.CreateFileQueryWithOptions(queryOptions);
                    IReadOnlyList <StorageFile> episodeFiles = await queryResult.GetFilesAsync();

                    foreach (StorageFile episodeFile in episodeFiles)
                    {
                        Episode episode = new Episode(-1, episodeFile.Path);
                        season.AddEpisode(episode);
                    }
                }

                PlexViewModel.Shows.Add(show);
            }
        }