public override async Task <bool> PrepareAsync(CookieAwareWebClient client, CancellationToken cancellation) { var description = await client.DownloadStringTaskAsync( "https://cloud-api.yandex.net:443/v1/disk/public/resources/download?public_key=" + HttpUtility.UrlEncode(Url)); if (cancellation.IsCancellationRequested) { return(false); } Url = (string)JObject.Parse(description)["href"]; Logging.Write("Yandex Disk download link: " + Url); try { var query = HttpUtility.ParseQueryString(Url); FileName = query["filename"]; if (FlexibleParser.TryParseLong(query["fsize"], out var size)) { TotalSize = size; } } catch (Exception) { // ignored } return(true); }
private static SevenZipEntry ParseListOfFiles_Line(string line) { if (line.Length < 20) { return(null); } var m = RegexParseLine.Match(line); if (!m.Success) { return(null); } var key = m.Groups[3].Value; return(m.Groups[1].Value.StartsWith("D") ? null : new SevenZipEntry { Key = key.Trim(), Size = FlexibleParser.TryParseLong(m.Groups[2].Value) ?? 0L }); }
public long GetLong([NotNull, LocalizationRequired(false)] string key, int defaultValue) { return(FlexibleParser.TryParseLong(GetPossiblyEmpty(key)) ?? defaultValue); }
public long?GetLongNullable([NotNull, LocalizationRequired(false)] string key) { return(FlexibleParser.TryParseLong(GetPossiblyEmpty(key))); }