Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
It's an alternative for BeautifulSoup
"""
url = self.construct_playlist_url()
req = request.get(url)
# split the page source by line and process each line
content = [x for x in req.split('\n') if 'pl-video-title-link' in x]
link_list = [x.split('href="', 1)[1].split('&', 1)[0] for x in content]
# The above only returns 100 or fewer links
# Simulating a browser request for the load more link
load_more_url = self._load_more_url(req)
while len(load_more_url): # there is an url found
logger.debug('load more url: %s' % load_more_url)
req = request.get(load_more_url)
load_more = json.loads(req)
videos = re.findall(
r'href=\"(/watch\?v=[\w-]*)',
load_more['content_html'],
)
# remove duplicates
link_list.extend(list(OrderedDict.fromkeys(videos)))
load_more_url = self._load_more_url(
load_more['load_more_widget_html'],
)
return link_list
:rtype: None
"""
self.watch_html = request.get(url=self.watch_url)
if '
def filesize(self):
"""File size of the media stream in bytes.
:rtype: int
:returns:
Filesize (in bytes) of the stream.
"""
if self._filesize is None:
headers = request.get(self.url, headers=True)
self._filesize = int(headers['content-length'])
return self._filesize
def prefetch(self):
"""Eagerly download all necessary data.
Eagerly executes all necessary network requests so all other
operations don't does need to make calls outside of the interpreter
which blocks for long periods of time.
:rtype: None
"""
self.watch_html = request.get(url=self.watch_url)
if '
self.watch_html = request.get(url=self.watch_url)
if '