Пример #1
0
        private async Task <EztvTorrent> GetMagnetForEpisode(Show show, Episode episode, bool getHD = false)
        {
            try
            {
                var episodeTorrents = await GetEpisodeTorrentList(show, episode);

                foreach (EztvTorrent link in episodeTorrents)
                {
                    if ((getHD && link.IsHD()) || (!getHD && !link.IsHD()))
                    {
                        return(link);
                    }
                }

                //string url = show.GetEZTVLink();

                //if (string.IsNullOrEmpty(url)) return null;

                //CQ htmlText;
                //using (WebClient client = new WebClient())
                //{
                //	htmlText = await client.DownloadStringTaskAsync(url);
                //}

                //if (htmlText == null) return null;

                //List<IDomObject> magnetLinks = htmlText.Select("a[class='magnet']").ToList();
                //List<string> episodeMagnetLinks = new List<string>();

                //foreach (var obj in magnetLinks)
                //{
                //	string magnetLink = obj.GetAttribute("href");
                //	bool magnetLinkIsHD = magnetLink.Contains("720p") || magnetLink.Contains("1080p");

                //	foreach (string format in episodeFormats)
                //	{
                //		string fullEpisode = string.Format(format, episode.AiredSeason, episode.AiredEpisodeNumber);

                //		if (magnetLink.ToLower().Contains(fullEpisode))
                //		{
                //			episodeMagnetLinks.Add(magnetLink);
                //			break;
                //			//if (getHD && magnetLinkIsHD)
                //			//	return magnetLink;
                //		}
                //	}
                //}
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }

            return(null);
        }
Пример #2
0
        public Eztv GetEztvShowDetails(string showName)
        {
            try
            {
                if (!File.Exists(AppGlobal.Paths.EztvIDFile))
                {
                    return(null);
                }

                // Check if showName starts with "The"
                showName = CommonMethods.GetListedName(showName);

                string[] lines = File.ReadAllLines(AppGlobal.Paths.EztvIDFile);
                string[] parts;
                string   tmp1 = showName.ToLower();
                string   tmp2;

                // Remove some strings
                tmp1 = tmp1.Replace("dc's ", "");

                foreach (string line in lines)
                {
                    parts = line.Split('|');
                    tmp2  = parts[2].ToLower();

                    // Remove brackets if there is only if they're NOT equal
                    if (tmp2 != tmp1)
                    {
                        if (tmp2.Contains("("))
                        {
                            tmp2 = tmp2.Substring(0, tmp2.IndexOf("(") - 1);
                        }

                        if (tmp1.Contains("("))
                        {
                            tmp1 = tmp1.Substring(0, tmp1.IndexOf("(") - 1);
                        }
                    }

                    if (tmp1 == tmp2 || tmp2 == tmp1.Replace("'", "") || tmp2.Contains(tmp1 + ":"))
                    {
                        return(new Eztv(parts[0], parts[1], parts[2]));
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }

            return(null);
        }
Пример #3
0
        public async Task <List <EztvTorrent> > GetEpisodeTorrentList(Show show, Episode episode)
        {
            try
            {
                string url = show.GetEZTVLink();

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


                ReturnResult <EztvAPI> eztvData = await Request.ExecuteAndDeserializeAsync <EztvAPI>("GET", $"https://eztv.ag/api/get-torrents?imdb_id={show.ImdbId.Substring(2)}&limit=100");

                var torrents        = eztvData.Result.Torrents;
                var episodeTorrents = new List <EztvTorrent>();

                foreach (EztvTorrent torrent in torrents)
                {
                    bool magnetLinkIsHD = torrent.IsHD();

                    foreach (string format in episodeFormats)
                    {
                        string fullEpisode = string.Format(format, episode.AiredSeason, episode.AiredEpisodeNumber);

                        if (torrent.Title.ToLower().Contains(fullEpisode))
                        {
                            episodeTorrents.Add(torrent);
                            break;
                        }
                    }
                }

                return(episodeTorrents);
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }

            return(null);
        }