mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-09-01 10:55:08 +02:00
Merge 211d67fad1
into e1b3fa242c
This commit is contained in:
commit
f5d8acf121
@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import random
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
@ -29,9 +30,19 @@ class RedditIE(InfoExtractor):
|
||||
},
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _gen_session_id():
|
||||
# The actual value of the cookie does not seem to matter.
|
||||
# Using a random 16-char hex string for now.
|
||||
id_length = 16
|
||||
rand_max = 1 << (id_length * 4)
|
||||
return '%0.*x' % (id_length, random.randrange(rand_max))
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
|
||||
self._set_cookie('.reddit.com', 'reddit_session', RedditIE._gen_session_id())
|
||||
|
||||
formats = self._extract_m3u8_formats(
|
||||
'https://v.redd.it/%s/HLSPlaylist.m3u8' % video_id, video_id,
|
||||
'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
|
||||
@ -103,6 +114,8 @@ class RedditRIE(InfoExtractor):
|
||||
|
||||
video_id = self._match_id(url)
|
||||
|
||||
self._set_cookie('.reddit.com', 'reddit_session', RedditIE._gen_session_id())
|
||||
|
||||
data = self._download_json(
|
||||
url + '/.json', video_id)[0]['data']['children'][0]['data']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user