mirror of
https://github.com/zedeus/nitter
synced 2026-09-06 07:09:31 +00:00
Implement experimental mp4 streaming
This commit is contained in:
parent
d407051b66
commit
651941acd1
3 changed files with 87 additions and 60 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import strutils, strformat, uri, tables, base64
|
||||
import nimcrypto
|
||||
import types
|
||||
|
||||
var
|
||||
hmacKey: string
|
||||
|
|
@ -28,6 +29,20 @@ proc setProxyEncoding*(state: bool) =
|
|||
proc getHmac*(data: string): string =
|
||||
($hmac(sha256, hmacKey, data))[0 .. 12]
|
||||
|
||||
proc getBestMp4VidVariant(video: Video): VideoVariant =
|
||||
for v in video.variants:
|
||||
if v.bitrate >= result.bitrate:
|
||||
result = v
|
||||
|
||||
proc getVidVariant*(video: Video; playbackType: VideoType): VideoVariant =
|
||||
case playbackType
|
||||
of mp4:
|
||||
return video.getBestMp4VidVariant
|
||||
of m3u8, vmap:
|
||||
for variant in video.variants:
|
||||
if variant.contentType == playbackType:
|
||||
return variant
|
||||
|
||||
proc getVidUrl*(link: string): string =
|
||||
if link.len == 0: return
|
||||
let sig = getHmac(link)
|
||||
|
|
|
|||
Loading…
Reference in a new issue