internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: streamlink/streamlink

Issue:
Connectcast stream fails with "invalid url"
Attempting to load an active connectcast stream via `streamlink connectcast.tv/streamname` results in an error:
`error: Unable to open URL:  (Invalid URL '': No schema supplied. Perhaps you mean http://?)`

Similarly, using `http://connectcast.tv/streamname` for the url also fails.

Running on Windows, built with python 3.5.0rc2



Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/connectcast.py b/src/streamlink/plugins/connectcast.py
--- a/src/streamlink/plugins/connectcast.py
+++ b/src/streamlink/plugins/connectcast.py
@@ -3,13 +3,11 @@
 
 from streamlink.plugin import Plugin
 from streamlink.plugin.api import http, validate
-from streamlink.stream import HDSStream
-
-SWF_URL = "https://www.connectcast.tv/jwplayer/jwplayer.flash.swf"
-
-_url_re = re.compile("http(s)?://(\w+\.)?connectcast.tv/")
-_manifest_re = re.compile(".*data-playback=\"([^\"]*)\".*")
+from streamlink.stream import RTMPStream
 
+_url_re = re.compile(r"http(?:s)?://connectcast.tv/(\w+)?")
+_stream_re = re.compile(r'<video src="mp4:(.*?)"')
+_stream_url = "http://connectcast.tv/channel/stream/{channel}"
 
 class ConnectCast(Plugin):
     @classmethod
@@ -17,14 +15,15 @@ def can_handle_url(self, url):
         return _url_re.match(url)
 
     def _get_streams(self):
-        res = http.get(self.url)
-        match = _manifest_re.search(res.text)
-        manifest = match.group(1)
-        streams = {}
-        streams.update(
-            HDSStream.parse_manifest(self.session, manifest, pvswf=SWF_URL)
-        )
-        
-        return streams
+        url_match = _url_re.match(self.url)
+        stream_url = _stream_url.format(channel=url_match.group(1))
+        res = self.session.http.get(stream_url)
+        match = _stream_re.search(res.content)
+        if match:
+            params = dict(rtmp="rtmp://stream.connectcast.tv/live",
+                          playpath=match.group(1),
+                          live=True)
+
+            return dict(live=RTMPStream(self.session, params))
 
 __plugin__ = ConnectCast


Test patch:
Repository: streamlink/streamlink

Issue:
Piczel.tv support
This is [something I requested](https://github.com/chrippa/livestreamer/issues/1205) when this was livestreamer, and the author made a little headway in determining that it defaults to HTTP-DASH but there's also a HLS stream available. I've since switched over to streamlink.


Discussion:
Try this: https://raw.githubusercontent.com/intact/livestreamer/fe7bd9fc6ba50450e57af6dcd76cfe2400fb5ddc/src/livestreamer/plugins/piczel.py

But change every instance of "livestreamer" into "streamlink"

Yeah, I got the notification when they posted it on the linked issue. I'll let you know how it goes the next time I watch something on Piczel.


Resolving patch:
diff --git a/src/streamlink/plugins/piczel.py b/src/streamlink/plugins/piczel.py
new file mode 100644
--- /dev/null
+++ b/src/streamlink/plugins/piczel.py
@@ -0,0 +1,70 @@
+import re
+
+from streamlink.plugin import Plugin
+from streamlink.plugin.api import http, validate
+from streamlink.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


Test patch:
Repository: streamlink/streamlink

Issue:
Goodgame moved to the new version of the site
Goodgame moved to the new version of the site (https://github.com/chrippa/livestreamer/issues/1513 ; https://github.com/chrippa/livestreamer/issues/1518 ; https://github.com/chrippa/livestreamer/pull/1527). Fix the plugin please.


Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/goodgame.py b/src/streamlink/plugins/goodgame.py
--- a/src/streamlink/plugins/goodgame.py
+++ b/src/streamlink/plugins/goodgame.py
@@ -4,7 +4,7 @@
 from streamlink.plugin.api import http
 from streamlink.stream import HLSStream
 
-HLS_URL_FORMAT = "http://hls.goodgame.ru/hls/{0}{1}.m3u8"
+HLS_URL_FORMAT = "https://hls.goodgame.ru/hls/{0}{1}.m3u8"
 QUALITIES = {
     "1080p": "",
     "720p": "_720",
@@ -12,13 +12,8 @@
     "240p": "_240"
 }
 
-_url_re = re.compile("http://(?:www\.)?goodgame.ru/channel/(?P<user>\w+)")
-_stream_re = re.compile(
-    "meta property=\"og:video:iframe\" content=\"http://goodgame.ru/player/html\?(\w+)\""
-)
-_ddos_re = re.compile(
-    "document.cookie=\"(__DDOS_[^;]+)"
-)
+_url_re = re.compile("https://(?:www\.)?goodgame.ru/channel/(?P<user>\w+)")
+_stream_re = re.compile(r'var src = "([^"]+)";')
 
 class GoodGame(Plugin):
     @classmethod
@@ -36,11 +31,6 @@ def _get_streams(self):
         }
         res = http.get(self.url, headers=headers)
 
-        match = _ddos_re.search(res.text)
-        if (match):
-            headers["Cookie"] = match.group(1)
-            res = http.get(self.url, headers=headers)
-
         match = _stream_re.search(res.text)
         if not match:
             return


Test patch:
Repository: streamlink/streamlink

Issue:
younow.com is broken
They have changed the API url to this one: 
`https://api.younow.com/php/api/broadcast/info/curId=0/user=`
in:
https://github.com/streamlink/streamlink/blob/master/src/streamlink/plugins/younow.py#L9

It still needs rtmpdump.exe, so it will give you the following error, related to #56
`[cli][error] Could not open stream: Unable to find rtmpdump.exe command`
#81 fixes it, and the plugin works fine.


Discussion:
@beardypig Can you make a pull request for this too? I'm not a github expert, so I don't know how to do it, but the proposed modification fixes the plugin.

@stevek123 will do :-)


Resolving patch:
diff --git a/src/streamlink/plugins/younow.py b/src/streamlink/plugins/younow.py
--- a/src/streamlink/plugins/younow.py
+++ b/src/streamlink/plugins/younow.py
@@ -6,7 +6,7 @@
 from streamlink.plugin.api import http
 from streamlink.stream import RTMPStream
 
-jsonapi= "http://www.younow.com/php/api/broadcast/info/curId=0/user="
+jsonapi= "https://api.younow.com/php/api/broadcast/info/curId=0/user="
 
 # http://younow.com/channel/
 _url_re = re.compile("http(s)?://(\w+.)?younow.com/(?P<channel>[^/&?]+)")


Test patch:
Repository: streamlink/streamlink

Issue:
Connectcast:  can't use a string pattern on a bytes-like object
```
Traceback (most recent call last):
  File "/usr/bin/streamlink", line 11, in <module>
    load_entry_point('streamlink==0.0.2', 'console_scripts', 'streamlink')()
  File "/usr/lib/python3.4/site-packages/streamlink_cli/main.py", line 899, in m                                                                                                                ain
    handle_url()
  File "/usr/lib/python3.4/site-packages/streamlink_cli/main.py", line 479, in h                                                                                                                andle_url
    streams = fetch_streams(plugin)
  File "/usr/lib/python3.4/site-packages/streamlink_cli/main.py", line 392, in f                                                                                                                etch_streams
    sorting_excludes=args.stream_sorting_excludes)
  File "/usr/lib/python3.4/site-packages/streamlink/plugin/plugin.py", line 316,                                                                                                                 in get_streams
    return self.streams(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/streamlink/plugin/plugin.py", line 230,                                                                                                                 in streams
    ostreams = self._get_streams()
  File "/usr/lib/python3.4/site-packages/streamlink/plugins/connectcast.py", lin                                                                                                                e 21, in _get_streams
    match = _stream_re.search(res.content)
TypeError: can't use a string pattern on a bytes-like object
```


Discussion:
That's my bad...


Resolving patch:
diff --git a/src/streamlink/plugins/connectcast.py b/src/streamlink/plugins/connectcast.py
--- a/src/streamlink/plugins/connectcast.py
+++ b/src/streamlink/plugins/connectcast.py
@@ -18,7 +18,7 @@ def _get_streams(self):
         url_match = _url_re.match(self.url)
         stream_url = _stream_url.format(channel=url_match.group(1))
         res = self.session.http.get(stream_url)
-        match = _stream_re.search(res.content)
+        match = _stream_re.search(res.text)
         if match:
             params = dict(rtmp="rtmp://stream.connectcast.tv/live",
                           playpath=match.group(1),


Test patch:
Repository: streamlink/streamlink

Issue:
cybergame.tv plugin not work for livestreams
`[cli][info] Found matching plugin cybergame for URL http://cybergame.tv/sharkisfinetoo/`
`[cli][info] Available streams: 720p (worst, best)`
`[cli][info] Opening stream: 720p (rtmp)`
`[cli][error] No data returned from stream`
For stream
`http://cybergame.tv/<channel>`
Internet Download Manager  produces a link like
`rtmp://cybergametv.cdnvideo.ru/cybergame//<channel>`
VODs fine.


Discussion:
Does that stream URL work? I could not get it to work. 

With some wiresharking I managed to get it working with `rtmp://stream1.cybergame.tv:2936/live/<channel>`. 

 @beardypig Sorry. Your is work. My no longer works(yesterday works).

OK, that's weird ... maybe they change it frequently? 

I found the RTMP URL in the end, it was in `http://api.cybergame.tv/p/embed.php?c=<channel>&type=embed&w=100pc&h=100pc&auto=true&advforced=true&nick=` eg. http://api.cybergame.tv/p/embed.php?c=op-mizantrop&type=embed&w=100pc&h=100pc&auto=true&advforced=true&nick=

![111](https://cloud.githubusercontent.com/assets/14862821/20174529/acb3f8d8-a757-11e6-86ee-b605e7034cf4.JPG) - maybe it help? (view-source:http://api.cybergame.tv/p/embed.php?c=ebrellika&type=embed&w=100pc&h=100pc&auto=true&advforced=true)

That's what i was referring to :)

Sorry. Now I understood. I do not know much English:)

No problem :D 

I will check it over the next few days as see if it changes, and make the necessary changes to the plugin. 

OK! Thanks!


Resolving patch:
diff --git a/src/streamlink/plugins/cybergame.py b/src/streamlink/plugins/cybergame.py
--- a/src/streamlink/plugins/cybergame.py
+++ b/src/streamlink/plugins/cybergame.py
@@ -5,6 +5,7 @@
 from streamlink.plugin.api import http, validate
 from streamlink.stream import RTMPStream
 
+LIVE_STREAM_URL = "rtmp://stream1.cybergame.tv:2936/live/"
 PLAYLIST_URL = "http://api.cybergame.tv/p/playlist.smil"
 
 _url_re = re.compile("""
@@ -46,7 +47,7 @@
 
 class Cybergame(Plugin):
     @classmethod
-    def can_handle_url(self, url):
+    def can_handle_url(cls, url):
         return _url_re.match(url)
 
     def _get_playlist(self, **params):
@@ -75,6 +76,10 @@ def _get_streams(self):
         if video_id:
             return self._get_playlist(vod=video_id)
         elif channel:
-            return self._get_playlist(channel=channel)
+            return {'live': RTMPStream(
+                self.session,
+                dict(rtmp=LIVE_STREAM_URL, app="live", pageUrl=self.url, playpath=channel, live=True)
+            )}
+
 
 __plugin__ = Cybergame


Test patch:
Repository: streamlink/streamlink

Issue:
Error with using --twitch-oauth-authenticate

Using that causes a browser to open to http://livestreamer.tanuki.se/en/develop/twitch_oauth.html?error=redirect_mismatch&error_description=Parameter+redirect_uri+does+not+match+registered+URI   In the main.py file this link is show http://streamlink.tanuki.se/en/develop/twitch_oauth.html when it should link to this https://streamlink.github.io/twitch_oauth.html  https://github.com/streamlink/streamlink/blob/master/src/streamlink_cli/main.py#L536

https://github.com/streamlink/streamlink/issues/4#issuecomment-261737748


Discussion:

Resolving patch:
diff --git a/src/streamlink_cli/main.py b/src/streamlink_cli/main.py
--- a/src/streamlink_cli/main.py
+++ b/src/streamlink_cli/main.py
@@ -533,7 +533,7 @@ def authenticate_twitch_oauth():
        access to their Twitch account."""
 
     client_id = TWITCH_CLIENT_ID
-    redirect_uri = "http://streamlink.tanuki.se/en/develop/twitch_oauth.html"
+    redirect_uri = "https://streamlink.github.io/twitch_oauth.html"
     url = ("https://api.twitch.tv/kraken/oauth2/authorize/"
            "?response_type=token&client_id={0}&redirect_uri="
            "{1}&scope=user_read+user_subscriptions").format(client_id, redirect_uri)


Test patch:
Repository: streamlink/streamlink

Issue:
NHK live issue
Hello guys and thanks for continuing the work on this amazing tool .

Was trying to see infos on Nhk live and despite listed as supported in the plugins list i can't get it to work : 

Stream Link: http://www3.nhk.or.jp/nhkworld/en/live/

and windows console response : 

[Streamlink for Windows]
[cli][info] Found matching plugin nhkworld for URL http://www3.nhk.or.jp/nhkworld/en/live/
error: Unable to open URL: http://api.sh.nhk.fivecool.tv/api/cdn/?publicId=3bz2huey&playerId=7Dy (HTTPConnectionPool(host='api.sh.nhk.fivecool.tv', port=80): Max retries exceeded with url: /api/cdn/?publicId=3bz2huey&playerId=7Dy (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x01DD
8650>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed',)))
[End of Streamlink for Windows]

Thanks a lot .



Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/nhkworld.py b/src/streamlink/plugins/nhkworld.py
--- a/src/streamlink/plugins/nhkworld.py
+++ b/src/streamlink/plugins/nhkworld.py
@@ -4,42 +4,28 @@
 
 from streamlink.plugin import Plugin
 from streamlink.plugin.api import http, validate
-from streamlink.stream import HDSStream
+from streamlink.stream import HLSStream
 
-API_URL = "http://api.sh.nhk.fivecool.tv/api/cdn/?publicId=3bz2huey&playerId=7Dy"
+API_URL = "http://{}.nhk.or.jp/nhkworld/app/tv/hlslive_web.xml"
 
-_url_re = re.compile("http(s)?://(\w+\.)?nhk.or.jp/nhkworld")
-_schema = validate.Schema({
-    "live-streams": [{
-        "streams": validate.all(
-            [{
-                "protocol": validate.text,
-                "streamUrl": validate.text
-            }],
-            validate.filter(lambda s: s["protocol"] in ("http-flash", "http-hds"))
-        )
-    }]
-})
+_url_re = re.compile("http(?:s)?://(?:(\w+)\.)?nhk.or.jp/nhkworld")
+_schema = validate.Schema(
+        validate.xml_findtext("./main_url/wstrm")
+)
 
 
 class NHKWorld(Plugin):
     @classmethod
     def can_handle_url(cls, url):
-        return _url_re.match(url)
+        return _url_re.match(url) is not None
 
     def _get_streams(self):
-        res = http.get(API_URL)
-        data = http.json(res, schema=_schema)
-
-        streams = {}
-        for livestreams in data["live-streams"]:
-            for stream in livestreams["streams"]:
-                url = stream["streamUrl"]
-                for name, stream in HDSStream.parse_manifest(self.session, url).items():
-                    if name.endswith("k"):
-                        streams[name] = stream
-
-        return streams
+        # get the HLS xml from the same sub domain as the main url, defaulting to www
+        sdomain = _url_re.match(self.url).group(1) or "www"
+        res = http.get(API_URL.format(sdomain))
+
+        stream_url = http.xml(res, schema=_schema)
+        return HLSStream.parse_variant_playlist(self.session, stream_url)
 
 
 __plugin__ = NHKWorld


Test patch:
Repository: streamlink/streamlink

Issue:
TVCatchup addon not working anymore
root@ovh2:/data# streamlink http://tvcatchup.com/watch/channel4
[cli][info] streamlink is running as root! Be careful!
[cli][info] Found matching plugin tvcatchup for URL http://tvcatchup.com/watch/channel4
error: No streams found on this URL: http://tvcatchup.com/watch/channel4
root@ovh2:/data# streamlink --plugins
[cli][info] streamlink is running as root! Be careful!
Loaded plugins: adultswim, afreeca, afreecatv, aftonbladet, alieztv, antenna, ard_live, ard_mediathek, artetv, atresplayer, azubutv, bambuser, beam, beattv, bigo, bilibili, bliptv, chaturbate, cinergroup, connectcast, crunchyroll, cybergame, dailymotion, dingittv, disney_de, dmcloud, dmcloud_embed, dogan, dogus, dommune, douyutv, dplay, drdk, euronews, expressen, filmon, filmon_us, foxtr, furstream, gaminglive, gomexp, goodgame, hitbox, itvplayer, kanal7, letontv, livecodingtv, livestation, livestream, media_ccc_de, mediaklikk, meerkat, mips, mlgtv, nhkworld, nineanime, nos, npo, nrk, oldlivestream, openrectv, orf_tvthek, pandatv, periscope, picarto, piczel, powerapp, rtlxl, rtve, ruv, seemeplay, servustv, speedrunslive, sportschau, ssh101, stream, streamboat, streamingvideoprovider, streamlive, streamme, streamupcom, svtplay, tga, tigerdile, trt, turkuvaz, tv360, tv3cat, tv4play, tv8, tvcatchup, tvplayer, twitch, ustreamtv, vaughnlive, veetle, vgtv, viagame, viasat, viasat_embed, vidio, wattv, webtv, weeb, younow, youtube, zdf_mediathek



Discussion:
Looks like they have changed the site a bit. Unfortunately I can't look at it at the moment, I'm on holiday, but I'll take a look next week. Maybe someone else will have time to fix it before that. Sorry :-)
No hurry, enjoy your holiday :)

Resolving patch:
diff --git a/src/streamlink/plugins/tvcatchup.py b/src/streamlink/plugins/tvcatchup.py
--- a/src/streamlink/plugins/tvcatchup.py
+++ b/src/streamlink/plugins/tvcatchup.py
@@ -6,7 +6,7 @@
 
 USER_AGENT = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
 _url_re = re.compile("http://(?:www\.)?tvcatchup.com/watch/\w+")
-_stream_re = re.compile(r"\"(?P<stream_url>https?://.*m3u8\?.*clientKey=[^\"]*)\";")
+_stream_re = re.compile(r'''(?P<q>["'])(?P<stream_url>https?://.*m3u8\?.*clientKey=.*?)(?P=q)''')
 
 
 class TVCatchup(Plugin):
@@ -24,7 +24,7 @@ def _get_streams(self):
         match = _stream_re.search(res.text, re.IGNORECASE | re.MULTILINE)
 
         if match:
-            stream_url = match.groupdict()["stream_url"]
+            stream_url = match.group("stream_url")
 
             if stream_url:
                 if "_adp" in stream_url:


Test patch:
Repository: streamlink/streamlink

Issue:
Adult Swim doesn't play any streams.
https://www.adultswim.com/videos/streams
https://www.adultswim.com/videos/streams/toonami
https://www.adultswim.com/videos/streams/williams-stream


Discussion:
Can you please provide the command you're running, as well as what the error output looks like?
@gravyboat
```
$ streamlink -p mpv https://www.adultswim.com/videos/streams/toonami
error: No plugin can handle URL: https://www.adultswim.com/videos/streams/toonami
```
What version of Streamlink are you running? Your command (minus passing the player variable) works fine for me on `0.2.0`.
@stepshal that is a bug, if you drop the `s` from `https` it should work. I'm preparing a PR to fix it right now :)
@beardypig That's weird, it worked fine for me with `https`.
@gravyboat agreed, very weird...
@stepshal this should be fixed if you update to the latest nightly. 
@stepshal is this working with the latest nightly? 
@beardypig 
I have this:
`[cli][error] Could not open stream: Unable to open URL: http://adultswimhls-i.akamaihd.net/hls/live/249295/adultswim_6/main/1/stream_Layer4.m3u8 (403 Client Error: Forbidden for url: http://adultswimhls-i.akamaihd.net/hls/live/249295/adultswim_6/main/1/stream_Layer4.m3u8)` 
So it's geo-restricted? But i can watch it in browser.
Which URL are you trying to watch? I think some if not all are geo-restricted to the US. 
@beardypig i can watch all of them in browser without proxy. 
And do they all give the same error with streamlink?
@beardypig Seems that all streams work except Toonami. But i can still watch it in browser.
OK. I get same error when trying from outside the US. I'll try and correct it. 
@beardypig and all vods from archive doesn't work. It's showing live stream instead. 
VOD is not currently supported. The toonami stream is slightly weird, might take a little while to fix. 
@beardypig so pycryptodome is needed only for VODs, that are not yet supported?  
I can't remember if they were just encrypted or also had DRM. I'll take a look when I fix the toonami bug... 

Resolving patch:
diff --git a/src/streamlink/stream/hls.py b/src/streamlink/stream/hls.py
--- a/src/streamlink/stream/hls.py
+++ b/src/streamlink/stream/hls.py
@@ -320,8 +320,17 @@ def parse_variant_playlist(cls, session_, url, name_key="name",
             stream_name = (names.get(name_key) or names.get("name") or
                            names.get("pixels") or names.get("bitrate"))
 
-            if not stream_name or stream_name in streams:
+            if not stream_name:
                 continue
+            if stream_name in streams:  # rename duplicate streams
+                stream_name = "{0}_alt".format(stream_name)
+                num_alts = len(list(filter(lambda n: n.startswith(stream_name), streams.keys())))
+
+                # We shouldn't need more than 2 alt streams
+                if num_alts >= 2:
+                    continue
+                elif num_alts > 0:
+                    stream_name = "{0}{1}".format(stream_name, num_alts + 1)
 
             if check_streams:
                 try:


Test patch: