mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-17 01:25:11 +00:00
[openload] Randomize User-Agent (closes #20688)
This commit is contained in:
parent
c4341ea47e
commit
7fc3b68ad3
1 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -361,7 +362,7 @@ class OpenloadIE(InfoExtractor):
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
|
_USER_AGENT_TPL = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{major}.0.{build}.{patch} Safari/537.36'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_urls(webpage):
|
def _extract_urls(webpage):
|
||||||
|
@ -376,7 +377,11 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
url_pattern = 'https://%s/%%s/%s/' % (host, video_id)
|
url_pattern = 'https://%s/%%s/%s/' % (host, video_id)
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': self._USER_AGENT,
|
'User-Agent': self._USER_AGENT_TPL % {
|
||||||
|
'major': random.randint(63, 73),
|
||||||
|
'build': random.randint(3239, 3683),
|
||||||
|
'patch': random.randint(0, 100),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for path in ('embed', 'f'):
|
for path in ('embed', 'f'):
|
||||||
|
|
Loading…
Reference in a new issue