Skip to content
Open
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
42 changes: 31 additions & 11 deletions stripchat.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import os
import re

from streamlink.plugin import Plugin
from streamlink.plugin import HIGH_PRIORITY, Plugin, pluginmatcher
from streamlink.plugin.api import validate
from streamlink.stream import HLSStream

_url_re = re.compile(r"https?://(\w+\.)?stripchat\.com/(?P<username>[a-zA-Z0-9_-]+)")

_post_schema = validate.Schema(
{
"cam": validate.Schema({
'streamName' : validate.text,
'viewServers': validate.Schema({'flashphoner-hls': validate.text})
'streamName' : str
}),
"user": validate.Schema({
'user' : validate.Schema({
'status' : validate.text,
'isLive' : bool
'status' : str,
'isLive' : bool,
'broadcastServer': str
})
})
}
)

_url_re = re.compile(r"https?://(\w+\.)?stripchat\.com/(?P<username>[a-zA-Z0-9_-]+)")

@pluginmatcher(re.compile(r"https?://(\w+\.)?stripchat\.com/(?P<username>[a-zA-Z0-9_-]+)"))
@pluginmatcher(priority=HIGH_PRIORITY, pattern=re.compile("""
https?://(?:
sitenumberone
|adifferentsite
|somethingelse
)
/.+\.m3u8
""", re.VERBOSE))


class Stripchat(Plugin):
@classmethod
Expand All @@ -36,21 +47,30 @@ def _get_streams(self):
"X-Requested-With": "XMLHttpRequest",
"Referer": self.url,
}


#self.logger.info("API Call: " + api_call)

res = self.session.http.get(api_call, headers=headers)
#self.logger.info("API Response: " + str(res.json()))
data = self.session.http.json(res, schema=_post_schema)

self.logger.info("Broadcast Server: " + data["user"]["user"]["broadcastServer"])

server = "https://b-{0}.doppiocdn.com/hls/{1}/master_{1}.m3u8".format(data["cam"]["viewServers"]["flashphoner-hls"],data["cam"]["streamName"])
server = "https://edge-hls.doppiocdn.com/hls/{1}/master/{1}.m3u8".format(data["user"]["user"]["broadcastServer"],data["cam"]["streamName"])

server0 = "https://b-{0}.doppiocdn.com/hls/{1}/{1}.m3u8".format(data["cam"]["viewServers"]["flashphoner-hls"],data["cam"]["streamName"])
server0 = "https://edge-hls.doppiocdn.com/hls/{1}/master/{1}.m3u8".format(data["user"]["user"]["broadcastServer"],data["cam"]["streamName"])

self.logger.info("Stream status: {0}".format(data["user"]["user"]["status"]))
self.logger.info("Stream live?: {0}".format(data["user"]["user"]["isLive"]))

if (data["user"]["user"]["isLive"] is True and data["user"]["user"]["status"] == "public" and server):
if (data["user"]["user"]["isLive"] is True and data["user"]["user"]["status"] == "public"):
try:
for s in HLSStream.parse_variant_playlist(self.session,server,headers={'Referer': self.url}).items():
self.logger.info("Playlist Item: " + str(s))
yield s
except IOError as err:
self.logger.info("This here is a exception. Hello fren :)")
self.logger.info("The actual exception: " + str(err))
stream = HLSStream(self.session, server0)
yield "Auto", stream

Expand Down