b3d0NA / download-videos-from-graphy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Download Videos from Graphy or Spayee

Requirements:

  • ffmpeg
  • openssl
  • wget

Step 1: Getting the video data

  • Play the video you want to download
  • Open Developer Tools (Ctrl+Shift+I in Chrome)
  • Go to Network tab
  • Now reload the browser
  • Search for ".m3u8" :

image

  • Look for index.m3u8 or master.m3u8. Here I found index.m3u8, click on that:

image

  • Go to Preview tab
  • Copy the file name of resolution you want to download:

image

  • Search again by that file name:

image

  • Open that and go to headers tab then copy the request url:

image

  • Open it in a new tab and download the file.

The file you have just downloaded, it has all of the .ts files. (Don't need to know what is .ts :^)

Those ts are encrypted. So you have to decrypt that. You need a key to decrypt that. You will get the key in the source code. Let's see..

Step 2: Getting the decryption key

  • Go to the sources tab in the Developer Tools
  • Look for 'cdn.jsdelivr.net':

image

  • Expand that, expand npm, open the hls.js file
  • Pretty print the file:

image

  • Now search for 'this.decryptkey', and find the code like this then put a breakpoint at that line, after that pause the script:

image

  • Reload the browser, now the browser might not finish the loading. Don't worry
  • Go to console tab of the Developer tools, clear the console:

image

  • Paste this code and hit enter:
Array.prototype.map.call(this.decryptkey, x => ('00' +
x.toString(16)).slice(-2)).join('')

The output you will get is the key you need in order to decrypt the video files

Step 3: Downloading all of the .ts files

Now you have to download all of the .ts files

  • Open terminal (cmd for windows)
  • Open the m3u8 file you downloaded
  • Check the .ts files:

image

For me the m3u8 file link is - https://d2qny97nu4rj64.cloudfront.net/spees/w/o/62849985/v/6339af82c819310/u/636fd9da2ec532/t/99cc6d32e738/p/assets/videos/628222f8bf2b49985/2022/10/02/6339a819310/hls_500k_.m3u8 Note: Values have been changed for privacy

  • Remove the last parameter of the URL: https://d2qny97nu4rj64.cloudfront.net/spees/w/o/62849985/v/6339af82c819310/u/636fd9da2ec532/t/99cc6d32e738/p/assets/videos/628222f8bf2b49985/2022/10/02/6339a819310/

  • Add the first ts filename you found from m3u8 file and replace the text which changes at every ts with $i: https://d2qny97nu4rj64.cloudfront.net/spees/w/o/62849985/v/6339af82c819310/u/636fd9da2ec532/t/99cc6d32e738/p/assets/videos/628222f8bf2b49985/2022/10/02/6339a819310/hls_500k_$i.ts

  • Paste this to the terminal/cmd, replace with the link you just made by adding .ts: See how many ts do you have and replace the <limit_of_the_ts> with that value

for i in {1..<limit_of_the_ts>}; do wget "<link>" -O ->> "encrypted.ts"; done;

After editing hit enter. All of the ts will be downloaded now.

  • Decrypt that ts to mp4 now:
sh
openssl enc -aes-128-cbc -nosalt -d -in encrypted.ts -K '<the_key_you_got_in_console>' -iv '<iv_in_m3u8_file_without_0x>' > decrypted.mp4

Boom! You got the video but without audio. :)

  • To get the audio do the same thing -

First find the audio by searching

https://d2qny97nu4rj64.cloudfront.net/spees/w/o/62849985/v/6339af82c819310/u/636fd9da2ec532/t/99cc6d32e738/p/assets/videos/628222f8bf2b49985/2022/10/02/6339a819310/hls_audio_0_$i.ts

for i in {1..<limit_of_the_ts>}; do wget "<link>" -O ->> "encrypted.ts"; done;
sh
openssl enc -aes-128-cbc -nosalt -d -in encrypted.ts -K '<the_key_you_got_in_console>' -iv '<iv_in_m3u8_file_without_0x>' > audio.aac

Step 4 : Finish the process

Combine the audio and the video

sh
ffmpeg -i video.mp4 -i audio.aac -c copy output.mp4

About


Languages

Language:Python 100.0%