player=C:\Program Files\VideoLAN\VLC\vlc.exe player-args=--file-caching=5000 ffmpeg-ffmpeg=C:\streamlink-7.1.2\ffmpeg\ffmpeg.exe
import json import re from urllib.parse import urlparse, urlunparse, urljoin from streamlink.exceptions import PluginError, NoStreamsError from streamlink.plugin.api import validate, useragents from streamlink.plugin import Plugin, pluginmatcher from streamlink.stream import HLSStream from streamlink.utils import update_scheme CONST_AMF_GATEWAY_LOCATION = '/tools/amf.php' CONST_HEADERS = {'User-Agent': useragents.CHROME} url_re = re.compile(r"(http(s)?://)?(([\w\-_]+)\.)?bongacams(\d*)\.com/([\w\-_]+)") amf_msg_schema = validate.Schema({ "status": "success", "userData": {"username": str}, "localData": {"videoServerUrl": str}, "performerData": {"username": str} }) @pluginmatcher(url_re) class bongacams(Plugin): def _get_streams(self): match = url_re.match(self.url) if not match: raise PluginError("Invalid URL format") stream_page_scheme = 'https' subdomain = match.group(4) base_domain = "bongacams99.com" stream_page_path = match.group(6) full_domain = f"{subdomain}.{base_domain}" if subdomain else base_domain initial_url = urlunparse((stream_page_scheme, full_domain, stream_page_path, '', '', '')) http_session = self.session.http http_session.headers.update(CONST_HEADERS) r = http_session.get(initial_url) if '/profile/' in r.url: raise NoStreamsError(self.url) if not r.ok: self.logger.debug("Status code for {0}: {1}", r.url, r.status_code) raise NoStreamsError(self.url) if len(http_session.cookies) == 0: raise PluginError("Can't get cookies") baseurl = urlunparse((stream_page_scheme, full_domain, '', '', '', '')) amf_gateway_url = urljoin(baseurl, CONST_AMF_GATEWAY_LOCATION) stream_page_url = urljoin(baseurl, stream_page_path) headers = { 'User-Agent': useragents.CHROME, 'Referer': stream_page_url, 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' } data = f'method=getRoomData&args%5B%5D={stream_page_path}&args%5B%5D=false' self.logger.debug('DATA: {0}'.format(str(data))) r = http_session.post(url=amf_gateway_url, headers=headers, data=data) http_session.close() if r.status_code != 200: raise PluginError("Unexpected status code for {0}: {1}".format(r.url, r.status_code)) try: response_json = json.loads(r.text) if response_json.get("status") == "error": self.logger.error("----- GEOBLOCK -----") return stream_source_info = amf_msg_schema.validate(response_json) except Exception as e: if 'videoServerUrl' not in r.text: self.logger.error("Stream is currently offline") return raise PluginError(f"Failed to validate response: {e}") self.logger.debug("Source stream info:\n{0}".format(stream_source_info)) if not stream_source_info: return urlnoproto = stream_source_info['localData'].get('videoServerUrl') if not urlnoproto: self.logger.error("Stream is currently offline") return urlnoproto = update_scheme('https://', urlnoproto) performer = stream_source_info['performerData']['username'] hls_url = f'{urlnoproto}/hls/stream_{performer}/playlist.m3u8' if hls_url: self.logger.debug('HLS URL: {0}'.format(hls_url)) print(' HLS URL:', hls_url) print() try: for s in HLSStream.parse_variant_playlist(self.session, hls_url, headers=headers).items(): yield s except Exception as e: if '404' in str(e): self.logger.error('Stream is currently offline or private') else: self.logger.error(str(e)) return __plugin__ = bongacams
[cli][info] Found matching plugin bongacams for URL [url=https://ru4.bongacams20.com/batterfly]https://ru4.bongacams20.com/batterfly[/url] error: Unable to open URL: [url=https://bongacams20.com/batterfly]https://bongacams20.com/batterfly[/url] (403 Client Error: Forbidden for url: [url=https://bongacams20.com/batterfly)]https://bongacams20.com/batterfly)[/url]