Represents a Song file downloaded from SoundCloud
Inheritance: BaseStream
示例#1
0
        /// <summary>
        /// Parse the given link and send it to the appropriate stream downloader
        /// </summary>
        /// <param name="url">The link provided to the application from the view</param>
        /// <param name="view">The view to report progress back to</param>
        /// <param name="exit">Exit after download?</param>
        public static async void DownloadTrack(String url, InfoReportProxy view, bool exit = false)
        {
            CrashHandler.AddExtra("stream_url", url);
            try
            {
                BaseStream sound;
                if (url.Contains(@"/sets/"))
                    sound = new SCSetStream(url, view);
                else
                    sound = new SCTrackStream(url, view);

                var download = sound.Download();

                if (download != null && await download)
                    sound.Finish();
            }
            catch (Exception e)
            {
                CrashHandler.Throw("There was an issue downloading the stream!", e);
            }
            finally
            {
                CrashHandler.ClearExtras();
                if (exit)
                {
                    Application.Exit();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Gathers and prepares all of the tracks in the set for download
        /// </summary>
        /// <param name="url">The url to the set</param>
        /// <param name="view">The view to report progress back to</param>
        public SCSetStream(string url, InfoReportProxy view) : base(url, view)
        {
            var playlistData = SCPlaylistData.LoadData(url);

            if (playlistData == null)
            {
                throw new HandledException("Downloaded set information was corrupted!", true);
            }

            if (playlistData.Tracks.Length < 1)
            {
                throw new HandledException("Playlist does not contain any tracks!", true);
            }

            for (var index = 0; index < playlistData.Tracks.Length; index++)
            {
                View.Report(String.Format("Processing track {0}/{1}", index + 1, playlistData.Tracks.Length));
                var track           = playlistData.Tracks[index];
                var setItemReporter = new SetItemReportProxy(this, playlistData.Tracks.Length);
                try
                {
                    var trackHandler = new SCTrackStream(track.PermalinkUrl, setItemReporter, track);
                    _downloads.Add(trackHandler, null);
                }
                catch (Exception)
                {
                    // Mark the item failed if it couldn't be processed
                    setItemReporter.Close();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Gathers and prepares all of the tracks in the set for download
        /// </summary>
        /// <param name="url">The url to the set</param>
        /// <param name="view">The view to report progress back to</param>
        public SCSetStream(string url, InfoReportProxy view) : base(url, view)
        {
            var playlistData = SCPlaylistData.LoadData(url);
            if (playlistData == null)
                throw new HandledException("Downloaded set information was corrupted!", true);

            if (playlistData.Tracks.Length < 1)
                throw new HandledException("Playlist does not contain any tracks!", true);

            for (var index = 0; index < playlistData.Tracks.Length; index++)
            {
                View.Report(String.Format("Processing track {0}/{1}", index+1, playlistData.Tracks.Length));
                var track = playlistData.Tracks[index];
                var setItemReporter = new SetItemReportProxy(this, playlistData.Tracks.Length);
                try
                {
                    var trackHandler = new SCTrackStream(track.PermalinkUrl, setItemReporter, track);
                    _downloads.Add(trackHandler, null);
                }
                catch (Exception)
                {
                    // Mark the item failed if it couldn't be processed
                    setItemReporter.Close();
                }
            }
        }