Python Forum
Segmented video not playing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Segmented video not playing
#1
I know this is not the right way to approach the problem I am going to solve. I am watching a movie from Hotstar and now I want to download the movie to my desktop. O inspected the page and came to know that it is segmented file that is being loaded.

So I decided to download all the segmented parts of the video and then join them and make a complete video file.

I captured the URL of a segmented part at random and paste it in browser URL, that part is downloaded, and can be played on its own with VLC media player. But when I download the particular segment of the file using Python scripy, it gets downloaded but not VLC can't play the downloaded file.

What's wrong with it? Can anyone help?

import requests

url = 'https://hses.hotstar.com/videos/movies/hindi/1000215554/1000074189/phone/media-4/segment-1000.ts'
r = requests.get(url, allow_redirects=True)
open('hotstar'+str(1)+'.ts', 'wb').write(r.content)
Reply
#2
You need an account to use Hotstar and to download the video content, you need your session-id and/or cookie.
It's possible to re-use a cookie from your browser.

Quick search: https://github.com/borisbabic/browser_cookie3
import browser_cookie3
import requests

cj = browser_cookie3.firefox()
req = requests.get("http://google.com", cookies=cj)
print(req.cookies)
Then you get something like this.
Output:
<RequestsCookieJar[<Cookie 1P_JAR=2020-08-20-12 for .google.com/>, <Cookie NID=DDD=xxx-xxx-xxx-xx-xx-xxx for .google.com/>, <Cookie SIDCC=xxx-xxx for .google.com/>]>
So if you do this with hoststar, one time without cookies and one time with cookies, you should get different results of html.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
(Aug-20-2020, 12:39 PM)DeaD_EyE Wrote: You need an account to use Hotstar and to download the video content, you need your session-id and/or cookie.
It's possible to re-use a cookie from your browser.

Quick search: https://github.com/borisbabic/browser_cookie3
import browser_cookie3
import requests

cj = browser_cookie3.firefox()
req = requests.get("http://google.com", cookies=cj)
print(req.cookies)
Then you get something like this.
Output:
<RequestsCookieJar[<Cookie 1P_JAR=2020-08-20-12 for .google.com/>, <Cookie NID=DDD=xxx-xxx-xxx-xx-xx-xxx for .google.com/>, <Cookie SIDCC=xxx-xxx for .google.com/>]>
So if you do this with hoststar, one time without cookies and one time with cookies, you should get different results of html.

It still is not working. By the way, I am not logged in that website, you can watch a few videos for free.

cj = browser_cookie3.chrome(domain_name='www.hotstar.com')

url = 'https://hses.hotstar.com/videos/movies/hindi/1000215554/1000074189/phone/media-4/segment-1000.ts'
r = requests.get(url, cookies=cj)
open('hotstar'+str(1)+'.ts', 'wb').write(r.content)
I am getting the following errors.

Output:
Traceback (most recent call last): File "download.py", line 9, in <module> cj = browser_cookie3.chrome(domain_name='www.hotstar.com') File "/home/sourav/Desktop/Report/Hotstar Project/Drishyam/virenv/lib/python3.7/site-packages/browser_cookie3/__init__.py", line 465, in chrome return Chrome(cookie_file, domain_name).load() File "/home/sourav/Desktop/Report/Hotstar Project/Drishyam/virenv/lib/python3.7/site-packages/browser_cookie3/__init__.py", line 269, in load value = self._decrypt(item[5], item[6]) File "/home/sourav/Desktop/Report/Hotstar Project/Drishyam/virenv/lib/python3.7/site-packages/browser_cookie3/__init__.py", line 322, in _decrypt decrypted += cipher.feed() File "/home/sourav/Desktop/Report/Hotstar Project/Drishyam/virenv/lib/python3.7/site-packages/pyaes/blockfeeder.py", line 169, in feed result = self._final(self._buffer, self._padding) File "/home/sourav/Desktop/Report/Hotstar Project/Drishyam/virenv/lib/python3.7/site-packages/pyaes/blockfeeder.py", line 77, in _block_final_decrypt return strip_PKCS7_padding(self.decrypt(data)) File "/home/sourav/Desktop/Report/Hotstar Project/Drishyam/virenv/lib/python3.7/site-packages/pyaes/util.py", line 58, in strip_PKCS7_padding raise ValueError("invalid padding byte") ValueError: invalid padding byte
Reply
#4
If you have any issues with Hotstar service, please visit hotstar customer service
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020