Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the camsoda bot #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions parameters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
DOWNLOADS_DIR = 'downloads'
MIN_FREE_DISK_PERCENT = 1.0 # in %
DEBUG = False

# The camsoda bot ignores this setting in favor of a chrome useragent generated with the fake-useragent library
HTTP_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"

# You can enter a number to select a specific height.
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ termcolor
beautifulsoup4
websocket-client
ffmpy
m3u8
m3u8
curl_cffi
fake-useragent
3 changes: 1 addition & 2 deletions streamonitor/sites/cam4.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,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
13 changes: 8 additions & 5 deletions streamonitor/sites/camsoda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests
from curl_cffi import requests
from fake_useragent import UserAgent
from streamonitor.bot import Bot


Expand All @@ -13,16 +14,18 @@ def getWebsiteURL(self):
return "https://www.camsoda.com/" + self.username

def getVideoUrl(self):
v = "https://" + self.lastInfo['edge_servers'][0] + "/" + self.lastInfo['stream_name'] + \
"_v1/index.m3u8?token=" + self.lastInfo['token']
audio_params = "multitrack=true&filter=tracks:v4v3v2v1a1a2"
v = "https://" + self.lastInfo["edge_servers"][0] + "/" + self.lastInfo["stream_name"] + \
"_v1/index.ll.m3u8?" + audio_params + "&token=" + self.lastInfo["token"]
return self.getWantedResolutionPlaylist(v)

def getStatus(self):
headers = self.headers | {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent": UserAgent().chrome, # Override user agent from config with a chrome user agent
}

r = requests.get('https://www.camsoda.com/api/v1/video/vtoken/' + self.username, headers=headers)
r = requests.get('https://www.camsoda.com/api/v1/video/vtoken/' + self.username, headers=headers, impersonate='chrome')
if r.status_code != 200:
return Bot.Status.UNKNOWN

Expand Down