Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with decryption #83

Open
dexter101010 opened this issue Sep 21, 2020 · 5 comments
Open

Error with decryption #83

dexter101010 opened this issue Sep 21, 2020 · 5 comments

Comments

@dexter101010
Copy link

Hi all,

I am trying to downloading an encrypted stream but i get the following errors :

hlsdl-0.26>hlsdl -C cookies.txt -b -v -o "file.ts" -h "Referer=https://online.uninets.com/s/courses/5b6288fde4b0e2daaa77752f/take" "https://vcdn.spayee.in/spees/w/o/5b49b8f2e4b02ac9d5e71945/v/5caf25bce4b00db56cfa45a3/u/5cd933e1e4b0c2b0f7965a3b/t/e80dfde6264579bb5595ca590255fd5b/p/assets/videos/2019/04/11/5caf25bce4b00db56cfa45a3/hls_1M_.m3u8"

START media_playlist_get_links
END media_playlist_get_links
HLS Stream is AES-128 encrypted.
Media Playlist parsed successfully.
File already exists. Overwrite? (y/n) y
Downloading segments.
{"d_t":"vod"}
{"t_d":2926,"d_d":0, "d_s":0}
Downloading part 0
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 424896, out_size: 424880
{"t_d":2926,"d_d":2,"d_s":424880}
Downloading part 1
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 232560, out_size: 232544
Downloading part 2
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 130864, out_size: 130848
Downloading part 3

@selsta
Copy link
Owner

selsta commented Sep 21, 2020

Hmm, I’m not really familiar with this URI="k/timestamp" encryption.

@dexter101010
Copy link
Author

Hmm, I’m not really familiar with this URI="k/timestamp" encryption.

Hi ,

Maybe you can implement the following into your app :

import re
import logging

from Crypto.Cipher import AES
from streamlink import StreamError
from streamlink.plugin import Plugin
from streamlink.stream import HLSStream
from streamlink.stream.hls import HLSStreamWriter, HLSStreamReader

log = logging.getLogger(name)

class SpayeeStreamWriter(HLSStreamWriter):
def _decrypt_key(self,data):
tmp1 = data[0:16]
tmp2 = data[32:48]
dec1 = AES.new(tmp2,AES.MODE_ECB)
tmp3 = dec1.decrypt(tmp1)
dec2 = AES.new(tmp3,AES.MODE_ECB)
return dec2.decrypt(tmp2)

def create_decryptor(self, key, sequence):
    if key.method != "AES-128":
        raise StreamError("Unable to decrypt cipher {0}", key.method)

    if not self.key_uri_override and not key.uri:
        raise StreamError("Missing URI to decryption key")

    key_uri = self.key_uri_override if self.key_uri_override else key.uri

    if self.key_uri != key_uri:
        res = self.session.http.get(key_uri, exception=StreamError,
                                    retries=self.retries,
                                    **self.reader.request_params)
        res.encoding = "binary/octet-stream"
        self.key_data = self._decrypt_key(res.content)
        self.key_uri = key_uri

    iv = key.iv or num_to_iv(sequence)

    # Pad IV if needed
    iv = b"\x00" * (16 - len(iv)) + iv

    return AES.new(self.key_data, AES.MODE_CBC, iv)

class SpayeeStreamReader(HLSStreamReader):
writer = SpayeeStreamWriter

class SpayeeStream(HLSStream):
def open(self):
reader = SpayeeStreamReader(self)
reader.open()

    return reader

class Spayee(Plugin):
url_re = re.compile(r"""https://vcdn.spayee.in/.*.m3u8""")

def __init__(self, url):
    super(Spayee, self).__init__(url)

@classmethod
def can_handle_url(cls, url):
    return cls.url_re.match(url) is not None

def _get_streams(self):
    return {"live":SpayeeStream(self.session,self.url)}

plugin = Spayee

I am not a developer, so i don't know how to do it.

Thanks in advance!

@KrishanKumark08
Copy link

Hi all,

I am trying to downloading an encrypted stream but i get the following errors :

hlsdl-0.26>hlsdl -C cookies.txt -b -v -o "file.ts" -h "Referer=https://online.uninets.com/s/courses/5b6288fde4b0e2daaa77752f/take" "https://vcdn.spayee.in/spees/w/o/5b49b8f2e4b02ac9d5e71945/v/5caf25bce4b00db56cfa45a3/u/5cd933e1e4b0c2b0f7965a3b/t/e80dfde6264579bb5595ca590255fd5b/p/assets/videos/2019/04/11/5caf25bce4b00db56cfa45a3/hls_1M_.m3u8"

START media_playlist_get_links
END media_playlist_get_links
HLS Stream is AES-128 encrypted.
Media Playlist parsed successfully.
File already exists. Overwrite? (y/n) y
Downloading segments.
{"d_t":"vod"}
{"t_d":2926,"d_d":0, "d_s":0}
Downloading part 0
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 424896, out_size: 424880
{"t_d":2926,"d_d":2,"d_s":424880}
Downloading part 1
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 232560, out_size: 232544
Downloading part 2
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 130864, out_size: 130848
Downloading part 3

Hey! Have you found the method to download this ?

@KrishanKumark08
Copy link

Have you found the solution, then please do share!

@vman241308
Copy link

Hi Everyone.
I was faced with the same issue like above.
I should download m3u8 link on the browser on the source(https://playback.lifesize.com/#/publicvideo/93099d50-c119-4ca6-9a81-803fefcaa197?vcpubtoken=b1771177-94f8-4289-9f95-db76d96cd962) is loaded, but I can not access to m3u8 link out side of the browser which has not cookie.

In this case, please let me know the solution regarding HLSDL, if you have.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants