Skip to content

Commit

Permalink
Merge pull request #7 from whimsical-c4lic0/use-user-agent-from-library
Browse files Browse the repository at this point in the history
Use user agent from library instead of hard-coded values
  • Loading branch information
whimsical-c4lic0 authored Dec 21, 2024
2 parents a3c90bd + 8c20d83 commit d9177ba
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ websocket-client
ffmpy
m3u8
curl_cffi
fake-useragent
3 changes: 2 additions & 1 deletion streamonitor/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from time import sleep
from datetime import datetime
from threading import Thread
from fake_useragent import UserAgent

import requests
import requests.cookies
Expand All @@ -29,7 +30,7 @@ class Bot(Thread):
long_offline_timeout = 600

headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
"User-Agent": UserAgent().chrome
}

class Status(Enum):
Expand Down
3 changes: 1 addition & 2 deletions streamonitor/sites/cam4.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def getVideoUrl(self):
return self.getWantedResolutionPlaylist(self.lastInfo['cdnURL'])

def getStatus(self):
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0",
headers = self.headers | {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
}

Expand Down
1 change: 0 additions & 1 deletion streamonitor/sites/camsoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def getVideoUrl(self):
def getStatus(self):
headers = self.headers | {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
}

r = requests.get('https://www.camsoda.com/api/v1/video/vtoken/' + self.username, headers=headers, impersonate='chrome')
Expand Down

0 comments on commit d9177ba

Please sign in to comment.