Exemple #1
0
        public void Download(string args)
        {
            Status = Status.Downloading;
            string output = Youtubedl.Run(args);

            DownloadManager.Log(output);

            Match match = new Regex(@"(?<=\[ffmpeg\] Destination: )(.*?)(?=\n)").Match(output);

            if (match.Success)
            {
                Status       = Status.Downloaded;
                FileLocation = new Uri(match.Value);

                if (GetFormat() == Format.mp3)
                {
                    ReadMetadada();
                    DownloadCoverart();
                    WriteMetadata();
                }

                Rename();

                Console.WriteLine("\nDownloaded: " + FileLocation.LocalPath + " [RETURN]");
            }
        }
Exemple #2
0
        public static void DownloadQuery(string query)
        {
            Uri link = GetLink(query);

            if (link == null)
            {
                //No link search
                DownloadSong(new Song(query));
            }
            else
            {
                Host     host     = GetHost(link);
                LinkType linkType = GetLinkType(link, host);
                //YouTube link
                if (host == Host.YouTube)
                {
                    //YouTube playlist
                    if (linkType == LinkType.Playlist)
                    {
                        string args   = string.Format(PLAYLIST_ARGS, link.OriginalString);
                        string output = Youtubedl.Run(args);

                        List <Song> songs            = new List <Song>();
                        string[]    stringSeparators = new string[] { "\n" };
                        foreach (string id in output.Split(stringSeparators, StringSplitOptions.None))
                        {
                            if (id.Length == 11)
                            {
                                songs.Add(new Song(id));
                            }
                        }

                        DownloadList(songs);
                    }
                    //YouTube video
                    else
                    {
                        DownloadSong(new Song(link.OriginalString));
                    }
                }
            }
        }