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

Added plugin for piczel.tv #1534

Open
wants to merge 2 commits into
base: develop
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
1 change: 1 addition & 0 deletions docs/plugin_matrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ nrk - tv.nrk.no Yes Yes Streams may be geo-restrict
oldlivestream original.liv... [3]_ Yes No Only mobile streams are supported.
periscope periscope.tv Yes Yes Replay/VOD is supported.
picarto picarto.tv Yes --
piczel piczel.tv Yes --
rtve rtve.es Yes No
ruv ruv.is Yes Yes Streams may be geo-restricted to Iceland.
sbsdiscovery - kanal5play.se -- Yes
Expand Down
70 changes: 70 additions & 0 deletions src/livestreamer/plugins/piczel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import RTMPStream, HLSStream

STREAMS_URL = "https://piczel.tv:3000/streams/{0}?&page=1&sfw=false&live_only=true"
HLS_URL = "https://5810b93fdf674.streamlock.net:1936/live/{0}/playlist.m3u8"
RTMP_URL = "rtmp://piczel.tv:1935/live/{0}"

_url_re = re.compile("https://piczel.tv/watch/(\w+)")

_streams_schema = validate.Schema(
{
"type": validate.text,
"data": [
{
"id": int,
"live": bool,
"slug": validate.text
}
]
}
)

class Piczel(Plugin):
@classmethod
def can_handle_url(cls, url):
return _url_re.match(url)

def _get_streams(self):
match = _url_re.match(self.url)
if not match:
return

channel_name = match.group(1)

res = http.get(STREAMS_URL.format(channel_name))
streams = http.json(res, schema=_streams_schema)
if streams["type"] not in ("multi", "stream"):
return

for stream in streams["data"]:
if stream["slug"] != channel_name:
continue

if not stream["live"]:
return

streams = {}

try:
streams.update(HLSStream.parse_variant_playlist(self.session, HLS_URL.format(stream["id"])))
except IOError as e:
# fix for hosted offline streams
if "404 Client Error" in str(e):
return
raise

streams["rtmp"] = RTMPStream(self.session, {
"rtmp": RTMP_URL.format(stream["id"]),
"pageUrl": self.url,
"live": True
})

return streams

return

__plugin__ = Piczel