Last active
September 11, 2023 06:29
-
-
Save siumhossain/9ab77c32bc130069f5dc745a741242b1 to your computer and use it in GitHub Desktop.
video streming test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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