-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
支持ddyun m3u8解密
- Loading branch information
Showing
5 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace N_m3u8DL_CLI | ||
{ | ||
class DecodeDdyun | ||
{ | ||
public static string DecryptM3u8(byte[] byteArray) | ||
{ | ||
string tmp = DecodeNfmovies.DecryptM3u8(byteArray); | ||
if (tmp.StartsWith("duoduo.key")) | ||
{ | ||
tmp = Regex.Replace(tmp, @"#EXT-X-BYTERANGE:.*\s", ""); | ||
tmp = tmp.Replace("https:", "jump/https:") | ||
.Replace("inews.gtimg.com", "puui.qpic.cn"); | ||
} | ||
return tmp; | ||
} | ||
|
||
//https://player.ddyunp.com/jQuery.min.js?v1.5 | ||
public static string GetVaildM3u8Url(string url) | ||
{ | ||
//url: https://hls.ddyunp.com/ddyun/id/1/key/playlist.m3u8 | ||
string id = Regex.Match(url, @"\w{20,}").Value; | ||
string tm = Global.GetTimeStamp(false); | ||
string t = ((long.Parse(tm) / 0x186a0) * 0x64).ToString(); | ||
string tmp = id + "duoduo" + "1" + t; | ||
MD5 md5 = MD5.Create(); | ||
byte[] bs = Encoding.UTF8.GetBytes(tmp); | ||
byte[] hs = md5.ComputeHash(bs); | ||
StringBuilder sb = new StringBuilder(); | ||
foreach (byte b in hs) | ||
{ | ||
sb.Append(b.ToString("x2")); | ||
} | ||
string key = sb.ToString(); | ||
return Regex.Replace(url, @"1/\w{20,}", "1/" + key); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace N_m3u8DL_CLI | ||
{ | ||
class DecodeNfmovies | ||
{ | ||
//https://jx.nfmovies.com/hls.min.js | ||
public static string DecryptM3u8(byte[] byteArray) | ||
{ | ||
var t = byteArray; | ||
var decrypt = ""; | ||
if (137 == t[0] && 80 == t[1] && 130 == t[354] && 96 == t[353]) t = t.Skip(355).ToArray(); | ||
else | ||
{ | ||
if (137 != t[0] || 80 != t[1] || 130 != t[394] || 96 != t[393]) | ||
{ | ||
for (var i = 0; i < t.Length; i++) decrypt += Convert.ToChar(t[i]); | ||
return decrypt; | ||
} | ||
t = t.Skip(395).ToArray(); | ||
} | ||
using (var zipStream = | ||
new System.IO.Compression.GZipStream(new MemoryStream(t), System.IO.Compression.CompressionMode.Decompress)) | ||
{ | ||
using (StreamReader sr = new StreamReader(zipStream, Encoding.UTF8)) | ||
{ | ||
decrypt = sr.ReadToEnd(); | ||
} | ||
} | ||
return decrypt; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters