Skip to content

Instantly share code, notes, and snippets.

@siumhossain
Last active September 11, 2023 06:29
Show Gist options
  • Save siumhossain/9ab77c32bc130069f5dc745a741242b1 to your computer and use it in GitHub Desktop.
Save siumhossain/9ab77c32bc130069f5dc745a741242b1 to your computer and use it in GitHub Desktop.
video streming test
from locust import HttpUser, task, between
import re
class QuickstartUser(HttpUser):
def extract_links(self, response_content):
pattern = r'(/encrypted_video/[^ ]+\.ts)'
links = re.findall(pattern, response_content)
print('links \n',links)
return links
@task
def hello_world(self):
video_file_name = "lecture-83-workbook-view-zoom-PnXI9b_720p.m3u8"
token = "bfba1bccd0f2ba4352154eb4051c351c320d7ac2"
response = self.client.get(f"/playlists/via_token/{video_file_name}/?token={token}")
if response.status_code == 200:
links = self.extract_links(response.text)
for link in links:
response = self.client.get(link)
else:
print(f"Failed to fetch m3u8 content. Status code: {response.status_code}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment