Exemplo n.º 1
0
        public void Init(int animeID, GroupVideoQualityVM gvq)
        {
            this.Cursor = Cursors.Wait;

            GroupVideoQuality = gvq;
            AnimeID           = animeID;

            // get the videos
            try
            {
                List <JMMServerBinary.Contract_VideoDetailed> vidContracts = JMMServerVM.Instance.clientBinaryHTTP.GetFilesByGroupAndResolution(AnimeID,
                                                                                                                                                GroupVideoQuality.GroupName, GroupVideoQuality.Resolution, GroupVideoQuality.VideoSource, GroupVideoQuality.VideoBitDepth, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                vids = new List <VideoDetailedVM>();
                foreach (JMMServerBinary.Contract_VideoDetailed contract in vidContracts)
                {
                    VideoDetailedVM vid = new VideoDetailedVM(contract);
                    vids.Add(vid);
                }
                FileCount           = vids.Count;
                lbFiles.ItemsSource = vids;

                GroupName   = GroupVideoQuality.GroupName;
                SummaryText = string.Format("{0} - {1}", GroupVideoQuality.VideoSource, GroupVideoQuality.Resolution);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
        private void CommandBinding_DeleteAllFiles(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM;
                if (anime == null)
                {
                    return;
                }

                Window wdw = Window.GetWindow(this);
                if (obj.GetType() == typeof(GroupVideoQualityVM))
                {
                    GroupVideoQualityVM gvq = (GroupVideoQualityVM)obj;

                    this.Cursor = Cursors.Wait;
                    DeleteFilesForm frm = new DeleteFilesForm();
                    frm.Owner = wdw;
                    frm.Init(anime.AnimeID, gvq);
                    bool?result = frm.ShowDialog();
                    if (result.Value)
                    {
                        // refresh
                        RefreshRecords();
                    }

                    this.Cursor = Cursors.Arrow;
                }

                if (obj.GetType() == typeof(GroupFileSummaryVM))
                {
                    GroupFileSummaryVM gfs = (GroupFileSummaryVM)obj;

                    this.Cursor = Cursors.Wait;
                    DeleteFilesForm frm = new DeleteFilesForm();
                    frm.Owner = wdw;
                    frm.Init(anime.AnimeID, gfs);
                    bool?result = frm.ShowDialog();
                    if (result.Value)
                    {
                        // refresh
                        RefreshRecords();
                    }

                    this.Cursor = Cursors.Arrow;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        private void RefreshRecords()
        {
            try
            {
                IsDataLoading         = true;
                IsDataFinishedLoading = false;

                VideoQualityRecords.Clear();
                GroupSummaryRecords.Clear();

                TotalFileCount = 0;
                double fileSize = 0;

                AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM;
                if (anime == null)
                {
                    return;
                }

                if (IsGroupQualityDetails)
                {
                    List <JMMServerBinary.Contract_GroupVideoQuality> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(anime.AnimeID);
                    foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ)
                    {
                        GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract);
                        TotalFileCount += vidQual.FileCountNormal + vidQual.FileCountSpecials;
                        fileSize       += vidQual.TotalFileSize;
                        VideoQualityRecords.Add(vidQual);
                    }
                }

                if (IsGroupSummary)
                {
                    List <JMMServerBinary.Contract_GroupFileSummary> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupFileSummary(anime.AnimeID);
                    foreach (JMMServerBinary.Contract_GroupFileSummary contract in summ)
                    {
                        GroupFileSummaryVM vidQual = new GroupFileSummaryVM(contract);
                        TotalFileCount += vidQual.FileCountNormal + vidQual.FileCountSpecials;
                        fileSize       += vidQual.TotalFileSize;
                        GroupSummaryRecords.Add(vidQual);
                    }
                }

                TotalFileSize = Utils.FormatFileSize(fileSize);


                IsDataLoading         = false;
                IsDataFinishedLoading = true;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemplo n.º 4
0
        public void Init(int animeID, GroupVideoQualityVM gvq)
        {
            this.Cursor = Cursors.Wait;

            GroupVideoQuality = gvq;
            AnimeID           = animeID;

            // get the videos
            try
            {
                JMMServerVM.Instance.RefreshCloudAccounts();
                dict = JMMServerVM.Instance.FolderProviders.ToDictionary(a => a.CloudID ?? 0, a => new Tuple <string, BitmapImage>(a.Provider, a.Icon));
                chks = new Dictionary <string, bool>();
                Dictionary <string, BitmapImage> types = new Dictionary <string, BitmapImage>();

                List <JMMServerBinary.Contract_VideoDetailed> vidContracts = JMMServerVM.Instance.clientBinaryHTTP.GetFilesByGroupAndResolution(AnimeID,
                                                                                                                                                GroupVideoQuality.GroupName, GroupVideoQuality.Resolution, GroupVideoQuality.VideoSource, GroupVideoQuality.VideoBitDepth, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                vids = new List <VideoDetailedVM>();
                foreach (JMMServerBinary.Contract_VideoDetailed contract in vidContracts)
                {
                    VideoDetailedVM vid = new VideoDetailedVM(contract);
                    foreach (VideoLocal_PlaceVM vv in vid.Places)
                    {
                        Tuple <string, BitmapImage> tup = dict[vv.ImportFolder.CloudID ?? 0];
                        if (!types.ContainsKey(tup.Item1))
                        {
                            chks[tup.Item1] = true;
                            types.Add(tup.Item1, tup.Item2);
                        }
                    }
                    vids.Add(vid);
                }

                FileCount           = vids.Count;
                lbFiles.ItemsSource = vids;
                GroupName           = GroupVideoQuality.GroupName;
                SummaryText         = string.Format("{0} - {1}", GroupVideoQuality.VideoSource, GroupVideoQuality.Resolution);
                InitImportFolders(types);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
Exemplo n.º 5
0
		private void ShowEpisodeDetails(AnimeEpisodeVM ep)
		{
			dummyEpisodeSearch.Visible = false;
			AnimeSeriesVM series = JMMServerHelper.GetSeries(ep.AnimeSeriesID);
			if (series != null && series.AniDB_Anime != null)
			{

                SetGUIProperty(GuiProperty.SubGroup_AnimeName, series.AniDB_Anime.FormattedTitle);
                SetGUIProperty(GuiProperty.SubGroup_EpisodeName, ep.EpisodeNumberAndName);

                List<GroupVideoQualityVM> videoQualityRecords = new List<GroupVideoQualityVM>();
				List<JMMServerBinary.Contract_GroupVideoQuality> summ = new List<Contract_GroupVideoQuality>(JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(series.AniDB_Anime.AnimeID));
				foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ)
				{
					GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract);
					videoQualityRecords.Add(vidQual);
				}

				// apply sorting
				if (videoQualityRecords.Count > 0)
				{
					List<SortPropOrFieldAndDirection> sortlist = new List<SortPropOrFieldAndDirection>();
					sortlist.Add(new SortPropOrFieldAndDirection("FileCountNormal", true, SortType.eInteger));
					videoQualityRecords = Sorting.MultiSort<GroupVideoQualityVM>(videoQualityRecords, sortlist);

					string fileDetails = "";
					foreach (GroupVideoQualityVM gvq in videoQualityRecords)
						fileDetails += string.Format("{0}({1}/{2}/{3}bit) - {4} Files ({5})", gvq.GroupNameShort, gvq.Resolution, gvq.VideoSource, gvq.VideoBitDepth, gvq.FileCountNormal, gvq.NormalEpisodeNumberSummary)
							+ Environment.NewLine;


                    SetGUIProperty(GuiProperty.SubGroup_FileDetails, fileDetails);
                }
                else
                {
                    ClearGUIProperty(GuiProperty.SubGroup_FileDetails);
                }

                dummyEpisodeSearch.Visible = true;
			}
		}
Exemplo n.º 6
0
        void searchWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                List <TorrentLinkVM> links = e.Result as List <TorrentLinkVM>;
                TorrentCount = links.Count;

                foreach (TorrentLinkVM link in links)
                {
                    TorrentLinks.Add(link);
                }

                ViewTorrentLinks.Refresh();

                List <GroupVideoQualityVM> vidQualListTemp = new List <GroupVideoQualityVM>();

                if (CurrentSearchCriteria.SearchType == DownloadSearchType.Episode)
                {
                    AnimeEpisodeVM ep = CurrentSearchCriteria.SearchParameter as AnimeEpisodeVM;
                    if (ep.AniDB_Anime == null)
                    {
                        ep.RefreshAnime();
                    }
                    if (ep.AniDB_Anime != null)
                    {
                        List <JMMServerBinary.Contract_GroupVideoQuality> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(ep.AniDB_Anime.AnimeID);
                        foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ)
                        {
                            GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract);
                            vidQualListTemp.Add(vidQual);
                        }
                    }
                }
                if (CurrentSearchCriteria.SearchType == DownloadSearchType.Series)
                {
                    AniDB_AnimeVM anime = CurrentSearchCriteria.SearchParameter as AniDB_AnimeVM;
                    if (anime != null)
                    {
                        List <JMMServerBinary.Contract_GroupVideoQuality> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(anime.AnimeID);
                        foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ)
                        {
                            GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract);
                            vidQualListTemp.Add(vidQual);
                        }
                    }
                }

                ShowSubGroupSuggestions(vidQualListTemp);

                TorrentSearchStatus = string.Format("{0} Results", links.Count);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor    = Cursors.Arrow;
                this.IsEnabled = true;
            }
        }
Exemplo n.º 7
0
        public static List <TorrentLink> SearchTorrents(DownloadSearchCriteria search)
        {
            List <string>      parms = search.GetParms();
            List <TorrentLink> links = new List <TorrentLink>();


            TorrentsAnimeSuki   suki  = new TorrentsAnimeSuki();
            TorrentsBakaUpdates bakau = new TorrentsBakaUpdates();

            List <string> episodeGroupParms = new List <string>();

            // lets do something special for episodes
            if (BaseConfig.Settings.TorrentPreferOwnGroups && search.SearchType == DownloadSearchType.Episode)
            {
                AnimeEpisodeVM ep = search.SearchParameter as AnimeEpisodeVM;

                AnimeSeriesVM series = JMMServerHelper.GetSeries(ep.AnimeSeriesID);
                if (series != null && series.AniDB_Anime != null)
                {
                    List <GroupVideoQualityVM> videoQualityRecords         = new List <GroupVideoQualityVM>();
                    List <JMMServerBinary.Contract_GroupVideoQuality> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(series.AniDB_Anime.AnimeID);
                    foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ)
                    {
                        GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract);
                        videoQualityRecords.Add(vidQual);
                    }

                    // apply sorting
                    if (videoQualityRecords.Count > 0)
                    {
                        List <SortPropOrFieldAndDirection> sortlist = new List <SortPropOrFieldAndDirection>();
                        sortlist.Add(new SortPropOrFieldAndDirection("FileCountNormal", true, SortType.eInteger));
                        videoQualityRecords = Sorting.MultiSort <GroupVideoQualityVM>(videoQualityRecords, sortlist);
                    }

                    //only use the first 2
                    int i = 0;
                    foreach (GroupVideoQualityVM gvq in videoQualityRecords)
                    {
                        if (i == 2)
                        {
                            break;
                        }
                        if (!episodeGroupParms.Contains(gvq.GroupNameShort))
                        {
                            episodeGroupParms.Add(gvq.GroupNameShort);
                            i++;
                        }
                    }
                }
            }

            // if searching by series and BakaBT is enabled, use that first
            bool doneBakaBT = false;

            if (BaseConfig.Settings.TorrentSources.Contains(MyAnimePlugin3.Constants.TorrentSourceNames.BakaBT) && search.SearchType == DownloadSearchType.Series)
            {
                doneBakaBT = true;
                TorrentsBakaBT     bakbt      = new TorrentsBakaBT();
                List <TorrentLink> bakbtLinks = bakbt.GetTorrents(parms);
                links.AddRange(bakbtLinks);
            }

            bool doneAnimeBytes = false;

            if (BaseConfig.Settings.TorrentSources.Contains(MyAnimePlugin3.Constants.TorrentSourceNames.AnimeBytes) && search.SearchType == DownloadSearchType.Series)
            {
                doneAnimeBytes = true;
                TorrentsAnimeBytes abytes      = new TorrentsAnimeBytes();
                List <TorrentLink> abytesLinks = abytes.GetTorrents(parms);
                links.AddRange(abytesLinks);
            }

            foreach (string src in BaseConfig.Settings.TorrentSources)
            {
                if (src == MyAnimePlugin3.Constants.TorrentSourceNames.BakaBT && !doneBakaBT)
                {
                    TorrentsBakaBT     bakbt      = new TorrentsBakaBT();
                    List <TorrentLink> bakbtLinks = bakbt.GetTorrents(parms);
                    links.AddRange(bakbtLinks);
                }

                if (src == MyAnimePlugin3.Constants.TorrentSourceNames.BakaBT && !doneAnimeBytes)
                {
                    TorrentsAnimeBytes abytes      = new TorrentsAnimeBytes();
                    List <TorrentLink> abytesLinks = abytes.GetTorrents(parms);
                    links.AddRange(abytesLinks);
                }

                if (src == MyAnimePlugin3.Constants.TorrentSourceNames.Nyaa)
                {
                    TorrentsNyaa       nyaa    = new TorrentsNyaa();
                    List <TorrentLink> ttLinks = null;
                    Dictionary <string, TorrentLink> dictLinks = new Dictionary <string, TorrentLink>();

                    foreach (string grp in episodeGroupParms)
                    {
                        List <string> tempParms = new List <string>();
                        foreach (string parmTemp in parms)
                        {
                            tempParms.Add(parmTemp);
                        }
                        tempParms.Insert(0, grp);
                        ttLinks = nyaa.GetTorrents(tempParms);

                        BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString() + "(" + grp + ")");

                        // only use the first 20
                        int x = 0;
                        foreach (TorrentLink link in ttLinks)
                        {
                            if (x == 20)
                            {
                                break;
                            }
                            dictLinks[link.TorrentDownloadLink] = link;
                            BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString());
                        }
                    }

                    BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString());
                    ttLinks = nyaa.GetTorrents(parms);
                    foreach (TorrentLink link in ttLinks)
                    {
                        dictLinks[link.TorrentDownloadLink] = link;
                        BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString());
                    }

                    links.AddRange(dictLinks.Values);
                }

                if (src == MyAnimePlugin3.Constants.TorrentSourceNames.AnimeSuki)
                {
                    List <TorrentLink> sukiLinks = suki.GetTorrents(parms);
                    links.AddRange(sukiLinks);
                }

                if (src == MyAnimePlugin3.Constants.TorrentSourceNames.TT)
                {
                    TorrentsTokyoToshokan            tt        = new TorrentsTokyoToshokan();
                    List <TorrentLink>               ttLinks   = null;
                    Dictionary <string, TorrentLink> dictLinks = new Dictionary <string, TorrentLink>();

                    foreach (string grp in episodeGroupParms)
                    {
                        List <string> tempParms = new List <string>();
                        foreach (string parmTemp in parms)
                        {
                            tempParms.Add(parmTemp);
                        }
                        tempParms.Insert(0, grp);
                        ttLinks = tt.GetTorrents(tempParms);

                        BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString() + "(" + grp + ")");

                        // only use the first 20
                        int x = 0;
                        foreach (TorrentLink link in ttLinks)
                        {
                            if (x == 20)
                            {
                                break;
                            }
                            dictLinks[link.TorrentDownloadLink] = link;
                            BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString());
                        }
                    }

                    BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString());
                    ttLinks = tt.GetTorrents(parms);
                    foreach (TorrentLink link in ttLinks)
                    {
                        dictLinks[link.TorrentDownloadLink] = link;
                        BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString());
                    }

                    links.AddRange(dictLinks.Values);
                }

                if (src == MyAnimePlugin3.Constants.TorrentSourceNames.BakaUpdates)
                {
                    List <TorrentLink> bakauLinks = bakau.GetTorrents(parms);
                    links.AddRange(bakauLinks);
                }
            }



            return(links);
        }