Closed trocknet closed 9 years ago
What exactly do you mean? At least the RTMP stream works just fine here:
livestreamer "http://play.afreeca.com/sogoodtt" live
[cli][info] Found matching plugin afreeca for URL http://play.afreeca.com/sogoodtt
[cli][info] Available streams: live (worst, best), live_hls
[cli][info] Opening stream: live (rtmp)
Only when I try to access the HLS stream I get an error message:
livestreamer "http://play.afreeca.com/sogoodtt" live_hls
[cli][info] Found matching plugin afreeca for URL http://play.afreeca.com/sogoodtt
[cli][info] Available streams: live (worst, best), live_hls
[cli][info] Opening stream: live_hls (hls)
[cli][error] Could not open stream: Unable to open URL: http://chromecast.afreeca.gscdn.com/livestream-05/auth_playlist.m3u8 (400 Client Error: Bad Request)
I see you edited your original post. Next time be more specific, when you submit a bug report.
sorry,i will be more specific next time.
i try to fix it . but i don't known python ,and i can't code it in python-style.
import re
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import RTMPStream, HLSStream
CHANNEL_INFO_URL = "http://live.afreeca.com:8057/api/get_broad_state_list.php"
KEEP_ALIVE_URL = "{server}/stream_keepalive.html"
STREAM_INFO_URLS = {
"rtmp": "http://sessionmanager01.afreeca.tv:6060/broad_stream_assign.html",
"hls": "http://resourcemanager.afreeca.tv:9090/broad_stream_assign.html"
}
HLS_KEY_URL = "http://api.m.afreeca.com/broad/a/watch"
CHANNEL_RESULT_ERROR = 0
CHANNEL_RESULT_OK = 1
_url_re = re.compile("http(s)?://(\w+\.)?afreeca.com/(?P<username>\w+)")
_channel_schema = validate.Schema(
{
"CHANNEL": {
"RESULT": validate.transform(int),
"BROAD_INFOS": [{
"list": [{
"nBroadNo": validate.text
}]
}]
}
},
validate.get("CHANNEL")
)
_stream_schema = validate.Schema(
{
validate.optional("view_url"): validate.url(
scheme=validate.any("rtmp", "http")
)
}
)
class AfreecaTV(Plugin):
@classmethod
def can_handle_url(self, url):
return _url_re.match(url)
def _get_channel_info(self, username):
headers = {
"Referer": self.url
}
data = {
"uid": username
}
res = http.post(CHANNEL_INFO_URL, data=data, headers=headers)
return http.json(res, schema=_channel_schema)
def _get_hls_key(self, broadcast,username):
headers = {
"Referer": self.url
}
data = {
"bj_id": username,
"broad_no": broadcast
}
res = http.post(HLS_KEY_URL, data=data, headers=headers)
return http.json(res)
def _get_stream_info(self, broadcast, type):
params = {
"return_type": "gs_cdn",
"use_cors":"true",
"cors_origin_url":"m.afreeca.com",
"broad_no":"{broadcast}-mobile-hd-{type}".format(**locals()),
"broad_key": "{broadcast}-flash-hd-{type}".format(**locals())
}
res = http.get(STREAM_INFO_URLS[type], params=params)
return http.json(res, schema=_stream_schema)
def _get_hls_stream(self, broadcast,username):
keyjson=self._get_hls_key(broadcast,username)
if keyjson["result"] != CHANNEL_RESULT_OK:
return
key=keyjson["data"]["hls_authentication_key"]
info = self._get_stream_info(broadcast, "hls")
if "view_url" in info:
return HLSStream(self.session, info["view_url"]+"?aid="+key)
def _get_rtmp_stream(self, broadcast):
info = self._get_stream_info(broadcast, "rtmp")
if "view_url" in info:
params = dict(rtmp=info["view_url"])
return RTMPStream(self.session, params=params, redirect=True)
def _get_streams(self):
match = _url_re.match(self.url)
username = match.group("username")
channel = self._get_channel_info(username)
if channel["RESULT"] != CHANNEL_RESULT_OK:
return
broadcast = channel["BROAD_INFOS"][0]["list"][0]["nBroadNo"]
if not broadcast:
return
flash_stream = self._get_rtmp_stream(broadcast)
if flash_stream:
yield "live", flash_stream
mobile_stream = self._get_hls_stream(broadcast,username)
if mobile_stream:
yield "live", mobile_stream
__plugin__ = AfreecaTV
Just wanted to corroborate this issue. It appears many of the newer Afreeca streams are HLS-only, so there is no RTMP alternative available for them.
For example: afreeca.com/cantob afreeca.com/momo130
If there might be an easy fix available, it'd be much appreciated!
I'm running into the same issue..
[cli][info] Found matching plugin afreeca for URL afreeca.com/rlatjdgus228
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (hls)
[cli][error] Could not open stream: Unable to open URL: http://chromecast.afreeca.gscdn.com/livestream-02/auth_playlist.m3u8 (400 Client Error: Bad Request)
If run it with the option --player-passthrough hls
VLC launches successfully, but gives me the following error:
Your input can't be opened:
VLC is unable to open the MRL 'http://chromecast.afreeca.gscdn.com/livestream-02/auth_playlist.m3u8'. Check the log for details.
This is what appears in VLC's "messages" if I manage to open it before the error:
http error: error: HTTP/1.1 400 Bad Request
access_mms error: error: HTTP/1.1 400 Bad Request
core error: open of `http://chromecast.afreeca.gscdn.com/livestream-02/auth_playlist.m3u8' failed
@prech @astarrh just try my patch.it work for me. save the code to afreecatv.py and replace afreecatv.pyc.
@prech @astarrh just try my patch.it work for me. save the code to afreecatv.py and replace afreecatv.pyc.
Thank you, that worked beautifully! Works for both RTMP and HLS streams now!
@prech @astarrh just try my patch.it work for me. save the code to afreecatv.py and replace afreecatv.pyc.
Worked perfectly for me as well. Thanks trocknet!
thanks @trocknet ! worked great for me as well!
trocknet, thank you very much!!
(also, if you don't already know, you have moderator permissions at snipealot channels)
hi your solution works but now i can't view 19+ channel, can you help me fix it?
it seems that afreeca has fixed the "19+" hole......
no way to bypass the 19+ hole again?
hi.. i have same problem.. after trying this patch.. the streamer can stream hls.. but its buffering like crazy.. did anyone experience this too ?
oh and i got this error http://puu.sh/iYUM2/8bd80f783c.png
it seems that the cdn that afreeca use abroad is not avaliable,try Korean cdn ip.
So can you explain how to apply this patch, what I did was that I copied the code to a .py file, then I compiled it to .pyc and replaced afreeca.pyc with the new one but Im still getting the same error, meaning that I can't watch hls streams.
Thanks.
Anyone know how to bypass the +19 error? I'm not good at python, how can I help?
I know the way how to download 19+ stream http://d-c.kr/
Paste the link with 19+ stream, for example http://live.afreeca.com:8079/app/index.cgi?szType=read_ucc_bbs&szBjId=khm11903&nStationNo=11165615&nBbsNo=12301161&nTitleNo=26201740&nRowNum=15&szSkin=&nPageNo=1 and get download link
By the way, this patch given by trocknet works not perfectly Sometimes stream open with timer and no sound
Hope next livestreamer build will works good.
@nOLanSea how to get that link stream ? yeah. sometimes i have to close and open it again ...
i hope the streamer for hls more smooth (rtmp is fine)
patch for solve the timer and no sound problem: change the code in hls.py from
else:
content = res.content
self.reader.buffer.write(content)
to
else:
if sequence.segment.uri.find("afreeca") and (sequence.segment.uri.find("_0.TS") or sequence.segment.uri.find("_1.TS") or sequence.segment.uri.find("_2.TS")) and len(res.content)<250000:
return
content = res.content
self.reader.buffer.write(content)
@zelkovazone go to afreeca.com/id and click to "all broadcast" button @trocknet what is hls.py ? there is only hls.pyc in livestreamer-1.12.2-py2.7.egg\livestreamer\stream folder, which is can not be edited via notepad
@nOLanSea hls.py is here https://github.com/chrippa/livestreamer/blob/develop/src/livestreamer/stream/hls.py
can someone post like a step by step to fix the hls thing cause I kinda got lost doing it by myself. What prog do i have to use to implement the codes? thanks
trocknet, maybe it would be easier if you fork livestreamer's repository to your own. You make changes there, share them and make pull requests. So there is no confusion in applying patches.
I would like to, but I don't known python and I can't guarantee the quality.
@nOLanSea where is the "all broadcast button" can u show using pic ? i`m kinda lost at it..
Thanks for fixing this :)
timer problem again can anyone solve?
fixed...
change the code in hls.py from
else:
content = res.content
self.reader.buffer.write(content)
to
else:
if sequence.segment.uri.find("afreeca")!= -1 and (sequence.segment.uri.find("_0.TS")!= -1 or sequence.segment.uri.find("_1.TS")!= -1 or sequence.segment.uri.find("_2.TS")!= -1):
return
content = res.content
self.reader.buffer.write(content)
Thanks @trocknet, that fixed it! So glad for your help
thank trocknet for timer fix again by the way, al these fixed (afreecatv.py and hls.py) would be included in next livestreamer build?
Thanks a lot @trocknet , never stop being awesome
It seems Afreeca has changed over recent weeks and the 15 second timer is back -- is there a way to bypass the timer for HLS streams? I used @trocknet's trick with:
else:
if sequence.segment.uri.find("afreeca")!= -1 and (sequence.segment.uri.find("_0.TS")!= -1 or sequence.segment.uri.find("_1.TS")!= -1 or sequence.segment.uri.find("_2.TS")!= -1):
return
content = res.content
self.reader.buffer.write(content)
in the hls.pyc file, but it no longer appears to be working...
Thanks
rmtp stream work,but hls stream not work. thanks.