public static StreamUrl getStreamUrl(string ID, eSoundQuality eQuality, out string Errmsg) { string sQua = AIGS.Common.Convert.ConverEnumToString((int)eQuality, typeof(eSoundQuality), 0); StreamUrl oObj = get <StreamUrl>("tracks/" + ID + "/streamUrl", out Errmsg, new Dictionary <string, string>() { { "soundQuality", sQua } }, 3); return(oObj); }
public static string GetTrackFileName(Track track, StreamUrl stream) { string sName = track.Title; string sRet = PathHelper.ReplaceLimitChar(sName, "-"); string sExt = ".m4a"; if (stream.Url.IndexOf(".flac?") > 0) { sExt = ".flac"; } if (stream.Url.IndexOf(".mp4?") > 0) { sExt = ".mp4"; } return(sRet.Trim() + sExt); }
public static StreamUrl GetStreamUrl(string sID, string sQuality, out string Errmsg) { string sRet = Get("tracks/" + sID + "/streamUrl", out Errmsg, new Dictionary <string, string>() { { "soundQuality", sQuality } }, 3); if (string.IsNullOrEmpty(sRet) || !string.IsNullOrEmpty(Errmsg)) { return(null); } StreamUrl aRet = JsonHelper.ConverStringToObject <StreamUrl>(sRet); return(aRet); }
public static StreamUrl GetStreamUrl(string sID, string sQuality) { string sRet = Get("tracks/" + sID + "/streamUrl", new Dictionary <string, string>() { { "soundQuality", sQuality } }, 3); if (string.IsNullOrEmpty(sRet) || !string.IsNullOrEmpty(Errmsg)) { return(null); } StreamUrl aRet = JsonHelper.ConverStringToObject <StreamUrl>(sRet); aRet.FileSize = DownloadFileHepler.GetFileLength(aRet.Url); return(aRet); }
public static string GetTrackFileName(Track track, StreamUrl stream) { string sName = track.Title; if (!string.IsNullOrWhiteSpace(track.Version)) { sName += '(' + track.Version + ')'; } string sRet = PathHelper.ReplaceLimitChar(sName, "-"); string sExt = ".m4a"; if (stream.Url.IndexOf(".flac?") > 0) { sExt = ".flac"; } if (stream.Url.IndexOf(".mp4?") > 0) { sExt = ".mp4"; } return(sRet.Trim() + sExt); }
public static bool DecryptTrackFile(StreamUrl stream, string filepath) { try { if (!System.IO.File.Exists(filepath)) { return(false); } if (stream.EncryptionKey.IsBlank()) { return(true); } byte[] master_key = System.Convert.FromBase64String("UIlTTEMmmLfGowo/UC60x2H45W6MdGgTRfo/umg4754="); byte[] security_token = System.Convert.FromBase64String(stream.EncryptionKey); byte[] iv = security_token.Skip(0).Take(16).ToArray(); byte[] str = security_token.Skip(16).ToArray(); byte[] dec = AESHelper.Decrypt(str, master_key, iv); byte[] key = dec.Skip(0).Take(16).ToArray(); byte[] nonce = dec.Skip(16).Take(8).ToArray(); byte[] nonce2 = new byte[16]; nonce.CopyTo(nonce2, 0); byte[] txt = ReadFile(filepath); AES_CTR tool = new AES_CTR(key, nonce2); byte[] newt = tool.DecryptBytes(txt); bool bfalg = WriteFile(filepath, newt); return(bfalg); } catch { return(false); } }