示例#1
0
        public bool Retrieve()
        {
            if(Retrieved) { return true; }

            if(this.Filesize == 0) { return false; }

            btEngine.Scrapers.StreamHeaders sth = new btEngine.Scrapers.StreamHeaders();
            sth.FollowRedirects = false;
            sth.ScrapeURL = StreamURL + "?client_id=" + Engine.Config.ClientID;
            sth.TakeTurn();

            string templocation = sth.response.GetResponseHeader("Location");
            //Logging.Write("Stream Retrieval redirecting to " + templocation);
            sth = new btEngine.Scrapers.StreamHeaders();
            sth.FollowRedirects = false;
            sth.ScrapeURL = templocation;
            sth.GetStreamAtRip = false;
            sth.TakeTurn();

            sth.KnownMaxLength = this.Filesize;
            this.RawData = new byte[this.Filesize];
            this.RawData = sth.GetStreamBytes();
            this.Retrieved = true;

            //Logging.Write("Track: " + this.Title + " retrieved and ready for usage.");
            sth = null;

            return true;
        }
示例#2
0
        public int CalculateFilesize()
        {
            //	Determine the size of the track file.  This is normally a stream, and SoundCloud does not
            //	support the HTTP HEAD request method.  So it's pretty damn gay that I need to open the
            //	stream to determine the filesize.

            btEngine.Scrapers.StreamHeaders sth = new btEngine.Scrapers.StreamHeaders();
            sth.FollowRedirects = false;
            sth.ScrapeURL = StreamURL + "?client_id=" + Engine.Config.ClientID;
            sth.TakeTurn();

            string templocation = sth.response.GetResponseHeader("Location");

            sth = new btEngine.Scrapers.StreamHeaders();
            sth.FollowRedirects = false;
            sth.ScrapeURL = templocation;
            sth.LimitRange = true;
            sth.LimitRangeLower = 0;
            sth.LimitRangeUpper = 0;
            sth.TakeTurn();

            templocation = sth.response.GetResponseHeader("Content-Range");
            templocation = templocation.Replace("bytes 0-0/", "").Trim();
            int contlength = Int32.Parse(templocation);
            this.Filesize = contlength;

            //RawData = new byte[contlength];

            return contlength;
        }