예제 #1
0
 public SyncUtils(bool createPlaylists, ManifestUtils manifestUtil, DownloadUtils downloadUtil, PlaylistUtils playlistUtil)
 {
     PlaylistUtil     = playlistUtil;
     DownloadUtil     = downloadUtil;
     ManifestUtil     = manifestUtil;
     _createPlaylists = createPlaylists;
 }
예제 #2
0
        public string GetDownloadUrlFromProgressiveUrl(string progressiveUrl)
        {
            string json = string.Empty;

            json = DownloadUtils.httpClient.SendAsync(DownloadUtils.RequestMessageWithHeaders($"{progressiveUrl}?client_id={_clientID}", HttpMethod.Get, _oauthToken)).Result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            return(JObject.Parse(json)["url"].Value <string>());
        }
예제 #3
0
        public JsonObjectsV2.Track RetrieveJsonTrackFromV2Url(int trackId)
        {
            string json = string.Empty;

            json = DownloadUtils.httpClient.SendAsync(DownloadUtils.RequestMessageWithHeaders($"https://" + $"api-v2.soundcloud.com/tracks/{trackId}?client_id={_clientID}", HttpMethod.Get, _oauthToken)).Result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            return(JsonConvert.DeserializeObject <JsonObjectsV2.Track>(json));
        }
예제 #4
0
 public SyncUtils(bool createPlaylists, ManifestUtils manifestUtil, DownloadUtils downloadUtil, PlaylistUtils playlistUtil, CancellationTokenSource syncCancellationSource)
 {
     PlaylistUtil           = playlistUtil;
     DownloadUtil           = downloadUtil;
     ManifestUtil           = manifestUtil;
     _createPlaylists       = createPlaylists;
     SyncCancellationSource = syncCancellationSource;
 }
        public static HtmlAgilityPack.HtmlDocument DownloadPageFromUrl(string url)
        {
            var doc  = new HtmlAgilityPack.HtmlDocument();
            var page = DownloadUtils.httpClient.SendAsync(DownloadUtils.RequestMessageWithHeaders(url, HttpMethod.Get)).Result.Content.ReadAsStringAsync().GetAwaiter().GetResult();

            doc.LoadHtml(page);
            return(doc);
        }
예제 #6
0
        public string RetrieveJson(string url, int?limit = null, int?offset = null)
        {
            string json = null;

            if (limit == 0)
            {
                limit = null;
            }

            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }
            try
            {
                if (!url.Contains("client_id="))
                {
                    url += (url.Contains("?") ? "&" : "?") + "client_id=" + _clientID;
                }
                if (limit != null)
                {
                    url += "&limit=" + limit;
                }
                if (offset != null)
                {
                    url += "&offset=" + offset;
                }
                if (limit != null)
                {
                    url += "&linked_partitioning=1"; //will add next_href to the response
                }
                var result = DownloadUtils.httpClient.SendAsync(DownloadUtils.RequestMessageWithHeaders($"{url}", HttpMethod.Get)).Result;
                json = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                if (!result.IsSuccessStatusCode)
                {
                    throw new Exception(json);
                }
            }
            catch (Exception e)
            {
                _manifestUtil.ProgressUtil.HasErrors = true;
                ExceptionHandlerUtils.HandleException(e);
            }

            return(json);
        }