Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe7228e

Browse files
back-togravyboat
authored andcommitted
plugins.filmon: use /tv/ url and raise PluginError for invalid channels
1 parent 3f24fde commit fe7228e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/streamlink/plugins/filmon.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import logging
33
import time
44

5-
from streamlink import StreamError
6-
from streamlink.compat import urlparse
5+
from streamlink.exceptions import PluginError, StreamError
6+
from streamlink.compat import urlparse, urlunparse
77
from streamlink.plugin import Plugin
88
from streamlink.plugin.api import validate
99
from streamlink.stream import HLSStream, hls_playlist
@@ -158,6 +158,8 @@ def channel(self, channel):
158158
except Exception:
159159
log.debug("channel sleep {0}".format(_))
160160
time.sleep(0.75)
161+
else:
162+
raise PluginError("Unable to find 'self.api.channel' for {0}".format(channel))
161163
return self.session.http.json(res, schema=self.api_schema)
162164

163165
def vod(self, vod_id):
@@ -197,6 +199,9 @@ class Filmon(Plugin):
197199

198200
def __init__(self, url):
199201
super(Filmon, self).__init__(url)
202+
parsed = urlparse(self.url)
203+
if parsed.path.startswith("/channel/"):
204+
self.url = urlunparse(parsed._replace(path=parsed.path.replace("/channel/", "/tv/")))
200205
self.api = FilmOnAPI(self.session)
201206

202207
@classmethod
@@ -241,6 +246,9 @@ def _get_streams(self):
241246
else:
242247
_id = channel
243248

249+
if _id is None:
250+
raise PluginError("Unable to find channel ID: {0}".format(channel))
251+
244252
try:
245253
data = self.api.channel(_id)
246254
for stream in data["streams"]:

0 commit comments

Comments
 (0)