VideoHelp Forum
+ Reply to Thread
Results 1 to 27 of 27
Thread
  1. Member
    Join Date
    Dec 2021
    Location
    Scotland
    Search Comp PM
    And the good news is............................... 1080p at last!!!!!!!!!!!!!!!!!!!!!

    Still shitty 96Kbps audio.

    There's a slight difference. Before, the mpd appeared after first advert was completed. Now it doesn't appear until the whole bloody lot have played (effing 5 minutes worth!!).
    Quote Quote  
  2. Nice, thanks for the heads-up. Getting 1080p @ ~6000kbps is not too shabby, even if the audio is still garbage. Might be worth making a script for this site now.
    Quote Quote  
  3. Member
    Join Date
    Dec 2021
    Location
    Scotland
    Search Comp PM
    Originally Posted by stabbedbybrick View Post
    Nice, thanks for the heads-up. Getting 1080p @ ~6000kbps is not too shabby, even if the audio is still garbage. Might be worth making a script for this site now.
    OK, here's mine. Some will say not very sophisticated but vit works and I'm happy with it. Just drop this (I called it ch5.py) into the WKS-KEYS folder. You don't need a header.py file. To run: py ch5.py and follow instructions
    Code:
    #### version 20230205-1
    
    import os
    import base64
    import requests
    from pywidevine.L3.cdm import deviceconfig
    from base64 import b64encode
    from pywidevine.L3.decrypt.wvdecryptcustom import WvDecrypt
    import shutil
    import glob
    
    ##########useful when used within VS Code to tell it which directory you're in
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    ##########
    
    headers = {
        'Accept': '*/*',
        'Accept-Language': 'en-GB,en;q=0.9',
        'Connection': 'keep-alive',
    }
    
    def cls():
        # posix is os name for Linux or mac
        if(os.name == 'posix'):
            os.system('clear')  # clear is the bash command
        # else screen will be cleared for windows (os name is actually nt for Windows)
        else:
            os.system('cls')  # cls is the batch command
    
    def WV_Function(pssh, lic_url, cert_b64=None):
        wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)                   
        widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=None)
        license_b64 = b64encode(widevine_license.content)
        wvdecrypt.update_license(license_b64)
        Correct, keyswvdecrypt = wvdecrypt.start_process()
        if Correct:
            return keyswvdecrypt
    
    def generate_pssh(mpd):
        division = mpd.split("cenc:pssh")
        for i in division:
            if i[1:5] == "AAAA":
                break
    
        pssh = i[1:-2]
        print(f"PSSH is {pssh}")
        return pssh
    
    def filename():
        output_name = input("What do you want to call your final file? (do not include file .extension like .mp4) ")
        output_name = f"{output_name}.mp4"
        path = f"./Completed/{output_name}"
        # look to see if duplicate filename
        if os.path.isfile(path):
            print(f"\nyou already have a file called {output_name}. Choose another name\n")
            return filename()
        #look to see if any illegal characters in filename
        illegals = "@$%\/:*?\"<>|~`#^+=\{\};!"
        any_illegals = (set(output_name) & set(illegals))
        if not any_illegals:
            return output_name
        else:
            list_illegals = ' '.join(any_illegals)
            print(f"\nyou have included the following which are not legal characters:       {list_illegals}\n")
            return filename()
    
    
    cls()
    mpd_url = input("enter mpd URL: ")
    lic_url = input("\nenter licence URL: ")
    
    mpd = requests.get(mpd_url, headers = headers).text
    
    pssh = generate_pssh(mpd)
    
    #get KEY
    keys = WV_Function(pssh, lic_url)
    print("KID:KEY found is " + (keys[0]))
    keys = str(keys[0])
    division = keys.find(":")
    key = (keys[division+1:])
    print(f"   KEY# is {key}")
    
    print("\n\n")
    
    os.system(f'yt-dlp --allow-u -f bestvideo -N 6 "{mpd_url}" -o encryptVid.mp4')
    os.system(f'yt-dlp --allow-u -f bestaudio -N 6 "{mpd_url}" -o encryptAud.m4a')
    
    
    print("==============================\n\n Decrypting\n\n==============================")
    
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptVid.mp4 video_decrypt.mp4")
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptAud.m4a audio_decrypt.m4a")
    
    if not os.path.exists("Throwaway"):
        os.makedirs("Throwaway")
    
    if not os.path.exists("Completed"):
        os.makedirs("Completed")
    
    cls()
    print("\n\n\n")
    
    output_name = filename()
    
    os.system(f"ffmpeg -i video_decrypt.mp4  -i audio_decrypt.m4a -c:v copy -c:a copy mux_file.mp4")
    os.rename("mux_file.mp4", f'{output_name}')
    
    shutil.move(f'{output_name}', "./Completed")
    
    for data in glob.glob("*_decrypt*.*"):
        shutil.move(data,"./Throwaway")
    for data in glob.glob("encrypt*.*"):
        shutil.move(data,"./Throwaway")
    shutil.rmtree("./Throwaway")
    
    print(f"All done.\n\n Your final file '{output_name}' is in 'Completed' folder")
    It seems that some (not many) downloads have two audio options (one for AD). To make sure you get the correct audio stream, it seems that its ID is always 10 (I've now tried quite a few and it always seems to be the case).
    So, change line:
    os.system(f'yt-dlp --allow-u -f bestaudio -N 6 "{mpd_url}" -o encryptAud.m4a')
    to
    os.system(f'yt-dlp --allow-u -f 10 -N 6 "{mpd_url}" -o encryptAud.m4a')
    Last edited by deccavox; 15th Aug 2023 at 19:00.
    Quote Quote  
  4. im getting this error can u help plz

    \My5_1080p_WEBDL.py", line 6, in <module>
    from pywidevine.L3.cdm import deviceconfig
    ModuleNotFoundError: No module named 'pywidevine.L3'
    Quote Quote  
  5. update: got 1 1080p mpd/video but the next episodes download as 720p for some reason its not grabbing the best quality
    Last edited by Dannyboi; 16th Aug 2023 at 09:58.
    Quote Quote  
  6. for some reason its not grabbing and downloading 1080p video/mpd only 720p videos can u help please
    Quote Quote  
  7. Do not send me DM's
    Join Date
    Dec 2021
    Location
    Tórshavn
    Search Comp PM
    !. How in blue blazes are you getting the key WITHOUT the kid?
    2. Use Chrome browser to obtain the mpd
    Code:
    https://akadash0.akamaized.net/hydra/C5164552461/C5164552461A/20230809180211/C5164552461-tt.mpd?CMCD=ot%3Dm%2Csid%3D%22087903c8-3623-486b-8335-5733439c24f3%22
    3. MY5 uses two KID's but both supply the same key from the license server.
    KID:KEY -> fb03e420fbca46a28c0e80af28f2369b:3839f55e8424c1f52 3919370f9a10567
    KID:KEY -> e579bcbb19d2b5d881004a8088aeb84f:3839f55e8424c1f52 3919370f9a10567
    You should be able to do this in your sleep, you've told us all many times just how brilliant you are.
    Quote Quote  
  8. i have got both key and kid now cant get the 1080p mpds
    Last edited by Dannyboi; 16th Aug 2023 at 10:16.
    Quote Quote  
  9. Do not send me DM's
    Join Date
    Dec 2021
    Location
    Tórshavn
    Search Comp PM
    here's a little tip, try it on a newer programme. Something that was added to the catch up service AFTER they changed the stream resolution.
    Try it with say, todays Home and Away
    Code:
    https://www.channel5.com/home-and-away/season-2022/a1e7a3e3-6030-4fd5-a134-aec1f481aed4
    Or pay attention to the mpd.
    Code:
    https://akadash0.akamaized.net/hydra/C5164552463/C5164552463A/20230811205053/C5164552463_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%2296544783-abb6-47b7-b2ee-6a6c7925253d%22
    remove _720p
    Code:
    https://akadash0.akamaized.net/hydra/C5164552463/C5164552463A/20230811205053/C5164552463_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%2296544783-abb6-47b7-b2ee-6a6c7925253d%22
    Quote Quote  
  10. Originally Posted by Sorenb View Post
    here's a little tip, try it on a newer programme. Something that was added to the catch up service AFTER they changed the stream resolution.
    Try it with say, todays Home and Away
    Code:
    https://www.channel5.com/home-and-away/season-2022/a1e7a3e3-6030-4fd5-a134-aec1f481aed4
    https://www.channel5.com/show/wonders-of-the-moon-with-dara-o-briain/season-1/episode-1

    720p mpd https://akadash0.akamaized.net/hydra/C5455940001/C5455940001B/20230816113129/C54559400...6ce870f84d6%22
    Quote Quote  
  11. Do not send me DM's
    Join Date
    Dec 2021
    Location
    Tórshavn
    Search Comp PM
    Originally Posted by Dannyboi View Post
    i have got both key and kid now cant get the 1080p mpds for some reason im only getting 720p mpds and videos not 1080p

    see 720p mpd: https://akadash0.akamaized.net/hydra/C5311390001/C5311390001B/20230123180628/C53113900...00c7f813202%22

    tv show: https://www.channel5.com/show/we-love-dad-s-army
    Dads army 1080p mpd
    Code:
    https://akadash0.akamaized.net/hydra/C5311390001/C5311390001B/20230123180628/C5311390001_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%223c7c5067-d0f7-443b-a74b-f00c7f813202%22[
    Quote Quote  
  12. Originally Posted by Sorenb View Post
    here's a little tip, try it on a newer programme. Something that was added to the catch up service AFTER they changed the stream resolution.
    Try it with say, todays Home and Away
    Code:
    https://www.channel5.com/home-and-away/season-2022/a1e7a3e3-6030-4fd5-a134-aec1f481aed4
    Or pay attention to the mpd.
    Code:
    https://akadash0.akamaized.net/hydra/C5164552463/C5164552463A/20230811205053/C5164552463_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%2296544783-abb6-47b7-b2ee-6a6c7925253d%22
    remove _720p
    Code:
    https://akadash0.akamaized.net/hydra/C5164552463/C5164552463A/20230811205053/C5164552463_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%2296544783-abb6-47b7-b2ee-6a6c7925253d%22
    yea that worked thanks
    Quote Quote  
  13. Originally Posted by Sorenb View Post
    here's a little tip, try it on a newer programme. Something that was added to the catch up service AFTER they changed the stream resolution.
    Try it with say, todays Home and Away
    Code:
    https://www.channel5.com/home-and-away/season-2022/a1e7a3e3-6030-4fd5-a134-aec1f481aed4
    Or pay attention to the mpd.
    Code:
    https://akadash0.akamaized.net/hydra/C5164552463/C5164552463A/20230811205053/C5164552463_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%2296544783-abb6-47b7-b2ee-6a6c7925253d%22
    remove _720p
    Code:
    https://akadash0.akamaized.net/hydra/C5164552463/C5164552463A/20230811205053/C5164552463_720p-tt.mpd?CMCD=ot%3Dm%2Csid%3D%2296544783-abb6-47b7-b2ee-6a6c7925253d%22
    yea that worked
    Quote Quote  
  14. Member
    Join Date
    Dec 2021
    Location
    Scotland
    Search Comp PM
    Modified script to include when 720p is included in the mpd url:
    Code:
    #### version 20230205-1
    #### version 20230816-1  remove 720p from URL (if required) to give 1080p
    
    import os
    import base64
    import requests
    from pywidevine.L3.cdm import deviceconfig
    from base64 import b64encode
    from pywidevine.L3.decrypt.wvdecryptcustom import WvDecrypt
    import shutil
    import glob
    
    ##########useful when used within VS Code to tell it which directory you're in
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    ##########
    
    headers = {
        'Accept': '*/*',
        'Accept-Language': 'en-GB,en;q=0.9',
        'Connection': 'keep-alive',
    }
    
    def cls():
        # posix is os name for Linux or mac
        if(os.name == 'posix'):
            os.system('clear')  # clear is the bash command
        # else screen will be cleared for windows (os name is actually nt for Windows)
        else:
            os.system('cls')  # cls is the batch command
    
    def WV_Function(pssh, lic_url, cert_b64=None):
        wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)                   
        widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=None)
        license_b64 = b64encode(widevine_license.content)
        wvdecrypt.update_license(license_b64)
        Correct, keyswvdecrypt = wvdecrypt.start_process()
        if Correct:
            return keyswvdecrypt
    
    def generate_pssh(mpd):
        division = mpd.split("cenc:pssh")
        for i in division:
            if i[1:5] == "AAAA":
                break
    
        pssh = i[1:-2]
        print(f"PSSH is {pssh}")
        return pssh
    
    def filename():
        output_name = input("What do you want to call your final file? (do not include file .extension like .mp4) ")
        output_name = f"{output_name}.mp4"
        path = f"./Completed/{output_name}"
        # look to see if duplicate filename
        if os.path.isfile(path):
            print(f"\nyou already have a file called {output_name}. Choose another name\n")
            return filename()
        #look to see if any illegal characters in filename
        illegals = "@$%\/:*?\"<>|~`#^+=\{\};!"
        any_illegals = (set(output_name) & set(illegals))
        if not any_illegals:
            return output_name
        else:
            list_illegals = ' '.join(any_illegals)
            print(f"\nyou have included the following which are not legal characters:       {list_illegals}\n")
            return filename()
    
    
    cls()
    mpd_url = input("enter mpd URL: ")
    lic_url = input("\nenter licence URL: ")
    
    mpd = requests.get(mpd_url, headers = headers).text
    
    if '_720p' in mpd_url:
        mpd_url = mpd_url.replace('_720p', '')
    
    pssh = generate_pssh(mpd)
    
    #get KEY
    keys = WV_Function(pssh, lic_url)
    print("KID:KEY found is " + (keys[0]))
    keys = str(keys[0])
    division = keys.find(":")
    key = (keys[division+1:])
    print(f"   KEY# is {key}")
    
    print("\n\n")
    
    os.system(f'yt-dlp --allow-u -f bestvideo -N 6 "{mpd_url}" -o encryptVid.mp4')
    os.system(f'yt-dlp --allow-u -f 10 -N 6 "{mpd_url}" -o encryptAud.m4a')
    
    
    print("==============================\n\n Decrypting\n\n==============================")
    
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptVid.mp4 video_decrypt.mp4")
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptAud.m4a audio_decrypt.m4a")
    
    if not os.path.exists("Throwaway"):
        os.makedirs("Throwaway")
    
    if not os.path.exists("Completed"):
        os.makedirs("Completed")
    
    cls()
    print("\n\n\n")
    
    output_name = filename()
    
    os.system(f"ffmpeg -i video_decrypt.mp4  -i audio_decrypt.m4a -c:v copy -c:a copy mux_file.mp4")
    os.rename("mux_file.mp4", f'{output_name}')
    
    shutil.move(f'{output_name}', "./Completed")
    
    for data in glob.glob("*_decrypt*.*"):
        shutil.move(data,"./Throwaway")
    for data in glob.glob("encrypt*.*"):
        shutil.move(data,"./Throwaway")
    shutil.rmtree("./Throwaway")
    
    print(f"All done.\n\n Your final file '{output_name}' is in 'Completed' folder")
    Quote Quote  
  15. Originally Posted by deccavox View Post
    Modified script to include when 720p is included in the mpd url:
    Code:
    #### version 20230205-1
    #### version 20230816-1  remove 720p from URL (if required) to give 1080p
    
    import os
    import base64
    import requests
    from pywidevine.L3.cdm import deviceconfig
    from base64 import b64encode
    from pywidevine.L3.decrypt.wvdecryptcustom import WvDecrypt
    import shutil
    import glob
    
    ##########useful when used within VS Code to tell it which directory you're in
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    ##########
    
    headers = {
        'Accept': '*/*',
        'Accept-Language': 'en-GB,en;q=0.9',
        'Connection': 'keep-alive',
    }
    
    def cls():
        # posix is os name for Linux or mac
        if(os.name == 'posix'):
            os.system('clear')  # clear is the bash command
        # else screen will be cleared for windows (os name is actually nt for Windows)
        else:
            os.system('cls')  # cls is the batch command
    
    def WV_Function(pssh, lic_url, cert_b64=None):
        wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)                   
        widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=None)
        license_b64 = b64encode(widevine_license.content)
        wvdecrypt.update_license(license_b64)
        Correct, keyswvdecrypt = wvdecrypt.start_process()
        if Correct:
            return keyswvdecrypt
    
    def generate_pssh(mpd):
        division = mpd.split("cenc:pssh")
        for i in division:
            if i[1:5] == "AAAA":
                break
    
        pssh = i[1:-2]
        print(f"PSSH is {pssh}")
        return pssh
    
    def filename():
        output_name = input("What do you want to call your final file? (do not include file .extension like .mp4) ")
        output_name = f"{output_name}.mp4"
        path = f"./Completed/{output_name}"
        # look to see if duplicate filename
        if os.path.isfile(path):
            print(f"\nyou already have a file called {output_name}. Choose another name\n")
            return filename()
        #look to see if any illegal characters in filename
        illegals = "@$%\/:*?\"<>|~`#^+=\{\};!"
        any_illegals = (set(output_name) & set(illegals))
        if not any_illegals:
            return output_name
        else:
            list_illegals = ' '.join(any_illegals)
            print(f"\nyou have included the following which are not legal characters:       {list_illegals}\n")
            return filename()
    
    
    cls()
    mpd_url = input("enter mpd URL: ")
    lic_url = input("\nenter licence URL: ")
    
    mpd = requests.get(mpd_url, headers = headers).text
    
    if '_720p' in mpd_url:
        mpd_url = mpd_url.replace('_720p', '')
    
    pssh = generate_pssh(mpd)
    
    #get KEY
    keys = WV_Function(pssh, lic_url)
    print("KID:KEY found is " + (keys[0]))
    keys = str(keys[0])
    division = keys.find(":")
    key = (keys[division+1:])
    print(f"   KEY# is {key}")
    
    print("\n\n")
    
    os.system(f'yt-dlp --allow-u -f bestvideo -N 6 "{mpd_url}" -o encryptVid.mp4')
    os.system(f'yt-dlp --allow-u -f 10 -N 6 "{mpd_url}" -o encryptAud.m4a')
    
    
    print("==============================\n\n Decrypting\n\n==============================")
    
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptVid.mp4 video_decrypt.mp4")
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptAud.m4a audio_decrypt.m4a")
    
    if not os.path.exists("Throwaway"):
        os.makedirs("Throwaway")
    
    if not os.path.exists("Completed"):
        os.makedirs("Completed")
    
    cls()
    print("\n\n\n")
    
    output_name = filename()
    
    os.system(f"ffmpeg -i video_decrypt.mp4  -i audio_decrypt.m4a -c:v copy -c:a copy mux_file.mp4")
    os.rename("mux_file.mp4", f'{output_name}')
    
    shutil.move(f'{output_name}', "./Completed")
    
    for data in glob.glob("*_decrypt*.*"):
        shutil.move(data,"./Throwaway")
    for data in glob.glob("encrypt*.*"):
        shutil.move(data,"./Throwaway")
    shutil.rmtree("./Throwaway")
    
    print(f"All done.\n\n Your final file '{output_name}' is in 'Completed' folder")
    so we just add the mpd, the tool removes the 720p and downloads 720p yea, shame we cant just add the url instead of mpd

    is there a script like this to download from uktv in 1080p?
    Last edited by Dannyboi; 16th Aug 2023 at 14:29.
    Quote Quote  
  16. Do not send me DM's
    Join Date
    Dec 2021
    Location
    Tórshavn
    Search Comp PM
    There is.
    I've written quite a few. None in python, though.
    Quote Quote  
  17. Member
    Join Date
    Dec 2021
    Location
    Scotland
    Search Comp PM
    UKTV. Actually very similar to My5:
    Code:
    #### version 20230205-1
    
    import os
    import base64
    import requests
    from pywidevine.L3.cdm import deviceconfig
    from base64 import b64encode
    from pywidevine.L3.decrypt.wvdecryptcustom import WvDecrypt
    import shutil
    import glob
    
    ##########useful when used within VS Code to tell it which directory you're in
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    ##########
    
    headers = {
        'Accept': '*/*',
        'Accept-Language': 'en-GB,en;q=0.9',
        'Connection': 'keep-alive',
    }
    
    def cls():
        # posix is os name for Linux or mac
        if(os.name == 'posix'):
            os.system('clear')  # clear is the bash command
        # else screen will be cleared for windows (os name is actually nt for Windows)
        else:
            os.system('cls')  # cls is the batch command
    
    def WV_Function(pssh, lic_url, cert_b64=None):
        wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)                   
        widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=None)
        license_b64 = b64encode(widevine_license.content)
        wvdecrypt.update_license(license_b64)
        Correct, keyswvdecrypt = wvdecrypt.start_process()
        if Correct:
            return keyswvdecrypt
    
    def generate_pssh(mpd):
        division = mpd.split("cenc:pssh")
        for i in division:
            if i[1:5] == "AAAA":
                break
    
        pssh = i[1:-2]
        print(f"PSSH is {pssh}")
        return pssh
    
    def filename():
        output_name = input("What do you want to call your final file? (do not include file .extension like .mp4) ")
        output_name = f"{output_name}.mp4"
        path = f"./Completed/{output_name}"
        # look to see if duplicate filename
        if os.path.isfile(path):
            print(f"\nyou already have a file called {output_name}. Choose another name\n")
            return filename()
        #look to see if any illegal characters in filename
        illegals = "@$%\/:*?\"<>|~`#^+=\{\};!"
        any_illegals = (set(output_name) & set(illegals))
        if not any_illegals:
            return output_name
        else:
            list_illegals = ' '.join(any_illegals)
            print(f"\nyou have included the following which are not legal characters:       {list_illegals}\n")
            return filename()
    
    
    cls()
    mpd_url = input("enter mpd URL: ")
    lic_url = input("\nenter licence URL: ")
    
    mpd = requests.get(mpd_url, headers = headers).text
    
    pssh = generate_pssh(mpd)
    
    #get KEY
    keys = WV_Function(pssh, lic_url)
    print("KID:KEY found is " + (keys[0]))
    keys = str(keys[0])
    division = keys.find(":")
    key = (keys[division+1:])
    print(f"   KEY# is {key}")
    
    print("\n\n")
    
    os.system(f'yt-dlp --allow-u -f bestvideo -N 6 "{mpd_url}" -o encryptVid.mp4')
    os.system(f'yt-dlp --allow-u -f bestaudio -N 6 "{mpd_url}" -o encryptAud.m4a')
    
    
    print("==============================\n\n Decrypting\n\n==============================")
    
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptVid.mp4 video_decrypt.mp4")
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptAud.m4a audio_decrypt.m4a")
    
    if not os.path.exists("Throwaway"):
        os.makedirs("Throwaway")
    
    if not os.path.exists("Completed"):
        os.makedirs("Completed")
    
    cls()
    print("\n\n\n")
    
    output_name = filename()
    
    os.system(f"ffmpeg -i video_decrypt.mp4  -i audio_decrypt.m4a -c:v copy -c:a copy mux_file.mp4")
    os.rename("mux_file.mp4", f'{output_name}')
    
    shutil.move(f'{output_name}', "./Completed")
    
    for data in glob.glob("*_decrypt*.*"):
        shutil.move(data,"./Throwaway")
    for data in glob.glob("encrypt*.*"):
        shutil.move(data,"./Throwaway")
    shutil.rmtree("./Throwaway")
    
    print(f"All done.\n\n Your final file '{output_name}' is in 'Completed' folder")
    Quote Quote  
  18. Sorry to be a bother chaps,.... but does this uptodate script for my5 which auto selects 1080p still work,.... because i'm sure it was working last week, but after pasting the mpd into the elevated cmd prompt, it asks for the lic url,... so far so good,.... network tab, lic,... shows two calls... oddly neither work, but come up with errors. but only after showing some of the subtitles.
    https://www.channel5.com/show/holidaying-with-jane-mcdonald/season-1-5b86f94c-cf0a-4ff...6844/episode-3
    mpd https://akadash0.akamaized.net/hydra/C5466270003/C5466270003B/20230906122503/C54662700...%2Cst%3Dv%2Csu

    lic call 1 (using copy link address)
    https://cassie.channel5.com/api/v2/licences/widevine/491/C5466270003?expiry=1694551689...a5%22%2Cst%3Dv

    lic call 2
    https://cassie.channel5.com/api/v2/licences/widevine/491/C5466270003?expiry=1694551689...a5%22%2Cst%3Dv

    both lic calls seem identical but under preview tab both are different. using latest version of chrome win 10 64bit.
    (I just want to know where I'm going wrong please).

    I decided to give firefox a go.... and it did start to work... right up until i got this error....
    audio_decrypt.m4a: No such file or directory
    Traceback (most recent call last):
    File "D:\YT_Rips\WKS-KEYS\CH5.py", line 113, in <module>
    os.rename("mux_file.mp4", f'{output_name}')
    FileNotFoundError: [WinError 2] The system cannot find the file specified: 'mux_file.mp4' -> 'jms01e03.mp4'

    okay.... it's downloading vid, and decrypting,... but no audio???
    ------------------------------------------------------------------------------------------------------------------------------------


    Still trying to suss out what is going on.... the script as it looks when downloading

    [generic] Extracting URL: https://akadash0.akamaized.net/hydra/C5466270003/C5466270003B/20230906122503/C54662700...fa80fb3c096%22
    [generic] C5466270003_SD-tt: Downloading webpage
    WARNING: [generic] Falling back on generic information extractor
    [generic] C5466270003_SD-tt: Extracting information
    [info] C5466270003_SD-tt: Downloading 1 format(s): 1
    [download] encryptVid.mp4 has already been downloaded
    [download] 100% of 877.02MiB
    WARNING: You have asked for UNPLAYABLE formats to be listed/downloaded. This is a developer option intended for debugging.
    If you experience any issues while using this option, DO NOT open a bug report
    [generic] Extracting URL: https://akadash0.akamaized.net/hydra/C5466270003/C5466270003B/20230906122503/C54662700...fa80fb3c096%22
    [generic] C5466270003_SD-tt: Downloading webpage
    WARNING: [generic] Falling back on generic information extractor
    [generic] C5466270003_SD-tt: Extracting information
    ERROR: [generic] C5466270003_SD-tt: Requested format is not available. Use --list-formats for a list of available formats
    ==============================

    Decrypting

    ==============================

    I don't know if i am right or not,... but during the download is the audio called SD-tt ??

    I do not know if this will help but my version of yt-dlp is 2023.7.6.0 13.3mb
    Last edited by LastResort; 12th Sep 2023 at 13:52. Reason: change of browser
    Quote Quote  
  19. Member
    Join Date
    Dec 2021
    Location
    england
    Search Comp PM
    just remove _SD-tt you will be fine download video and audio
    Code:
    https://akadash0.akamaized.net/hydra/C5466270003/C5466270003B/20230906122503/C5466270003.mpd?CMCD=ot%3Dm%2Csid%3D%22e103d00b-4f64-42b6-946f-36cef2ec9932%22
    Quote Quote  
  20. Thank you for the reply iamghost,....

    That's insane..... just that part even stopped the 1080p stream,.... I was only getting 720p and no audio...

    Really appreciate your input and help. Thanks again.
    Quote Quote  
  21. Member
    Join Date
    Dec 2021
    Location
    Scotland
    Search Comp PM
    So far, I've found 3 variations within the mpd url ('_720p', '_SD' and '_SD-fixed-label'). There may be more. They all seem to have a common theme, so hopefully, this will deal with the lot:
    Code:
    #### version 20230205-1
    #### version 20230816-1  remove 720p from mpd_url (if required) to give 1080p
    #### version 20230908-1  remove '_SD-fixed-label' from mpd_url
    #### version 20230908-2  deal with '_SD-tt' in mpd_url
    #### version 20230910-1  deal with all variations in mpd_url between '_' and '-tt'
    
    import os
    import base64
    import requests
    from pywidevine.L3.cdm import deviceconfig
    from base64 import b64encode
    from pywidevine.L3.decrypt.wvdecryptcustom import WvDecrypt
    import shutil
    import glob
    
    ##########useful when used within VS Code to tell it which directory you're in
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    ##########
    
    headers = {
        'Accept': '*/*',
        'Accept-Language': 'en-GB,en;q=0.9',
        'Connection': 'keep-alive',
    }
    
    def cls():
        # posix is os name for Linux or mac
        if(os.name == 'posix'):
            os.system('clear')  # clear is the bash command
        # else screen will be cleared for windows (os name is actually nt for Windows)
        else:
            os.system('cls')  # cls is the batch command
    
    def WV_Function(pssh, lic_url, cert_b64=None):
        wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)                   
        widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=None)
        license_b64 = b64encode(widevine_license.content)
        wvdecrypt.update_license(license_b64)
        Correct, keyswvdecrypt = wvdecrypt.start_process()
        if Correct:
            return keyswvdecrypt
    
    def generate_pssh(mpd):
        division = mpd.split("cenc:pssh")
        for i in division:
            if i[1:5] == "AAAA":
                break
    
        pssh = i[1:-2]
        print(f"PSSH is {pssh}")
        return pssh
    
    def filename():
        output_name = input("What do you want to call your final file? (do not include file .extension like .mp4) ")
        output_name = f"{output_name}.mp4"
        path = f"./Completed/{output_name}"
        # look to see if duplicate filename
        if os.path.isfile(path):
            print(f"\nyou already have a file called {output_name}. Choose another name\n")
            return filename()
        #look to see if any illegal characters in filename
        illegals = "@$%\/:*?\"<>|~`#^+=\{\};!"
        any_illegals = (set(output_name) & set(illegals))
        if not any_illegals:
            return output_name
        else:
            list_illegals = ' '.join(any_illegals)
            print(f"\nyou have included the following which are not legal characters:       {list_illegals}\n")
            return filename()
    
    
    cls()
    mpd_url = input("enter mpd URL: ")
    lic_url = input("\nenter licence URL: ")
    
    mpd = requests.get(mpd_url, headers = headers).text
    
    mpd_url = mpd_url[:mpd_url.find('_')] + mpd_url[mpd_url.find('-tt'):]
        
    pssh = generate_pssh(mpd)
    
    #get KEY
    keys = WV_Function(pssh, lic_url)
    print("KID:KEY found is " + (keys[0]))
    keys = str(keys[0])
    division = keys.find(":")
    key = (keys[division+1:])
    print(f"   KEY# is {key}")
    
    print("\n\n")
    
    os.system(f'yt-dlp --allow-u -f bestvideo -N 6 "{mpd_url}" -o encryptVid.mp4')
    os.system(f'yt-dlp --allow-u -f 10 -N 6 "{mpd_url}" -o encryptAud.m4a')
    
    
    print("==============================\n\n Decrypting\n\n==============================")
    
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptVid.mp4 video_decrypt.mp4")
    os.system(f"mp4decrypt --show-progress --key 1:{key} encryptAud.m4a audio_decrypt.m4a")
    
    if not os.path.exists("Throwaway"):
        os.makedirs("Throwaway")
    
    if not os.path.exists("Completed"):
        os.makedirs("Completed")
    
    cls()
    print("\n\n\n")
    
    output_name = filename()
    
    os.system(f"ffmpeg -i video_decrypt.mp4  -i audio_decrypt.m4a -c:v copy -c:a copy mux_file.mp4")
    os.rename("mux_file.mp4", f'{output_name}')
    
    shutil.move(f'{output_name}', "./Completed")
    
    for data in glob.glob("*_decrypt*.*"):
        shutil.move(data,"./Throwaway")
    for data in glob.glob("encrypt*.*"):
        shutil.move(data,"./Throwaway")
    shutil.rmtree("./Throwaway")
    
    print(f"All done.\n\n Your final file '{output_name}' is in 'Completed' folder")
    Quote Quote  
  22. Member
    Join Date
    Nov 2022
    Location
    Europe
    Search PM
    Does anyone know how to access the API on channel5? I want to automate a script but they have some weird protection. Normally you would make a request with the correct headers and then parse the response data. But the response on channel5 is encrypted with what looks like AES? There's an IV and a data string but I can't find the key anywhere. First I thought the auth in the episode json would be the key, but apparantely not. And where the hell is that auth coming from anyway? It's all very annoying and I would love some pointers.
    Quote Quote  
  23. Originally Posted by scryclwn View Post
    Does anyone know how to access the API on channel5? I want to automate a script but they have some weird protection. Normally you would make a request with the correct headers and then parse the response data. But the response on channel5 is encrypted with what looks like AES? There's an IV and a data string but I can't find the key anywhere. First I thought the auth in the episode json would be the key, but apparantely not. And where the hell is that auth coming from anyway? It's all very annoying and I would love some pointers.
    They use AES & HMAC ... and it changes regularly (it's changed at least twice since they added 1080p I believe)
    Last edited by T33V33; 13th Sep 2023 at 09:03.
    Quote Quote  
  24. Member
    Join Date
    Nov 2022
    Location
    Europe
    Search PM
    Originally Posted by T33V33 View Post
    Originally Posted by scryclwn View Post
    Does anyone know how to access the API on channel5? I want to automate a script but they have some weird protection. Normally you would make a request with the correct headers and then parse the response data. But the response on channel5 is encrypted with what looks like AES? There's an IV and a data string but I can't find the key anywhere. First I thought the auth in the episode json would be the key, but apparantely not. And where the hell is that auth coming from anyway? It's all very annoying and I would love some pointers.
    They use AES & HMAC ... and it changes regularly (it's changed at least twice since they added 1080p I believe)
    Oh damn, that sounds like it's above my skill level. You don't happen to have any tips on how to handle it?
    Quote Quote  
  25. Originally Posted by scryclwn View Post
    Originally Posted by T33V33 View Post
    Originally Posted by scryclwn View Post
    Does anyone know how to access the API on channel5? I want to automate a script but they have some weird protection. Normally you would make a request with the correct headers and then parse the response data. But the response on channel5 is encrypted with what looks like AES? There's an IV and a data string but I can't find the key anywhere. First I thought the auth in the episode json would be the key, but apparantely not. And where the hell is that auth coming from anyway? It's all very annoying and I would love some pointers.
    They use AES & HMAC ... and it changes regularly (it's changed at least twice since they added 1080p I believe)
    Oh damn, that sounds like it's above my skill level. You don't happen to have any tips on how to handle it?
    Unfortunately not
    Quote Quote  
  26. Member
    Join Date
    Nov 2022
    Location
    Europe
    Search PM
    Originally Posted by T33V33 View Post
    Unfortunately not
    That's okay, thanks anyway. You gave me some new information I can use in my searches, I appreciate that
    Quote Quote  
  27. This is my batch file for My5 downloading:

    Channel 5.bat
    -------------------------------------------------------------------------


    @ echo off

    echo Requirements; yt-dlp.exe , mp4decrypt.exe, aria2c .exe, ffmpeg.exe, CDRM-Project website.

    echo.

    echo Extentions for web browser; TamperMonkey, EME logger for TamperMonkey, MPD detector

    echo.

    set path=C:\Widevine

    set /p folder= Video Name to be Saved as (No spaces) :

    echo.

    mkdir C:\Widevine\Downloads\%folder%

    set /p stream=Input MPD URL :

    yt-dlp --external-downloader aria2c --allow-unplayable-formats -F "%stream%" -v

    echo.

    set /p video=Video Quality ID :

    echo.

    set /p audio=Audio Quality ID :

    echo.

    yt-dlp.exe --external-downloader aria2c --allow-unplayable-formats --verbose -f %video%+%audio% "%stream%" -o "C:\Widevine\Downloads\%folder%\encrypted.%%(ext)s "

    ren "C:\Widevine\Downloads\%folder%\*.mp4" encrypted.mp4

    ren "C:\Widevine\Downloads\%folder%\*.m4a" encrypted.m4a

    echo.

    set /p idkey1=Input 1st id:key from PSSH:

    echo.

    set /p idkey2=Input 2nd id:key from PSSH:

    echo.

    echo Decrypting and Merging .........

    mp4decrypt.exe --key %idkey1% --key %idkey2% C:\Widevine\Downloads\%folder%\encrypted.mp4 C:\Widevine\Downloads\%folder%\decrypted.mp4

    mp4decrypt.exe --key %idkey1% --key %idkey2% C:\Widevine\Downloads\%folder%\encrypted.m4a C:\Widevine\Downloads\%folder%\decrypted.m4a

    ffmpeg -hide_banner -i C:\Widevine\Downloads\%folder%\decrypted.mp4 -i C:\Widevine\Downloads\%folder%\decrypted.m4a -acodec copy -vcodec copy C:\Widevine\Downloads\%folder%.mp4

    RMDIR /s /q C:\Widevine\Downloads\%folder%

    ffplay C:\Widevine\Downloads\%folder%.mp4

    pause

    echo Completed .........

    cls
    -------------------------------------------------------------------------

    Works for me!
    Last edited by Oohjimaflip; 23rd Feb 2024 at 05:36.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!