Exemplo n.º 1
0
        private string DownloadHtml(string url)
        {
            var webClient = new WebDownloader(120000);

            Byte[] pageData = webClient.DownloadData(url);
            return(Encoding.ASCII.GetString(pageData));
        }
        /// <summary>
        /// Get album's page
        /// </summary>
        /// <returns>Parsed album's page</returns>
        public AlbumResult GetFullAlbum()
        {
            WebDownloader downloader = new WebDownloader(AlbumUrl);
            string        content    = downloader.DownloadData();

            return(WebContentParser.Parse <AlbumResult>(content));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get band's page
        /// </summary>
        /// <returns>Parsed band's page</returns>
        public BandResult GetFullBand()
        {
            WebDownloader downloader = new WebDownloader(BandUrl);
            string        content    = downloader.DownloadData();

            return(WebContentParser.Parse <BandResult>(content));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets list of band's albums simple list
        /// </summary>
        public IEnumerable <AlbumBandResult> GetAlbums(AlbumListType type)
        {
            WebDownloader wd      = new WebDownloader($@"https://www.metal-archives.com/band/discography/id/{Id}/tab/" + type.ToString().ToLower());
            string        content = wd.DownloadData();

            return(WebContentParser.ParseList <AlbumBandResult>(content));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets actual song's lyrics
        /// </summary>
        /// <returns>Lyrics or string.Empty if not exists</returns>
        public string GetLyrics()
        {
            string lyrics = string.Empty;

            if (HasLyrics)
            {
                WebDownloader wd = new WebDownloader($@"https://www.metal-archives.com/release/ajax-view-lyrics/id/{Id}");

                HtmlDocument document = new HtmlDocument();
                document.LoadHtml(wd.DownloadData());

                lyrics = document.DocumentNode.InnerText.Trim();
            }

            return(lyrics);
        }
Exemplo n.º 6
0
        /// <summary>
        /// If <see cref="NotesFullUrl"/> is not null, it returns full band's notes
        /// </summary>
        /// <returns>Band's notes</returns>
        public string GetFullNotes()
        {
            if (string.IsNullOrEmpty(NotesFullUrl))
            {
                return(string.Empty);
            }

            WebDownloader downloader = new WebDownloader(NotesFullUrl);
            string        content    = downloader.DownloadData();

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(content);

            return(doc.DocumentNode.InnerText);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Searches item by name.
        /// </summary>
        /// <param name="name">Item's name</param>
        /// <returns>List of items result - without pagination, all rows at once</returns>
        public IEnumerable <T> ByName(string name)
        {
            List <T> items = new List <T>();

            _configurator.Parameters["query"] = name;
            var             wd = new WebDownloader(_configurator.Url, _configurator.Parameters);
            IEnumerable <T> itemsToAdd;
            int             page = 0;

            do
            {
                _configurator.Parameters["iDisplayStart"] = (page++ *200).ToString();
                var response = wd.DownloadData();

                itemsToAdd = ProcessParse(response);
                items.AddRange(itemsToAdd);
            }while (itemsToAdd.Count() != 0);

            return(items);
        }
Exemplo n.º 8
0
        public FileInfo DownloadSubtitle(string downloadLink, string fileName)
        {
            if (null == downloadLink)
                throw new ArgumentNullException(nameof(downloadLink));

            string subtitleFile = Path.Combine(Path.GetTempPath(), fileName);
            string tempZipName = Path.GetTempFileName();

            try
            {
                var webClient = new WebDownloader();
                var data = webClient.DownloadData(downloadLink);
                using(var fileStream = new MemoryStream(data))
                {
                    UnzipSubtitleToFile(fileStream, subtitleFile);
                }
            }
            finally
            {
                File.Delete(tempZipName);
            }

            return new FileInfo(subtitleFile);
        }