Closed trocknet closed 9 years ago
m.afreeca.com and it's API are changed.
It is seems that afreeca has started to provide RTMP stream. http://play.afreeca.com/sogoodtt
I've investigated a bit and the flash player got these URLs for a stream I tested rtmp://101.79.243.142:1935/hotter2/definst/111640179-flash-hd-rtmp and rtmp://112.175.63.14:1935/hotter2/definst/111640179-flash-hd-rtmp Only the second one worked with that one, I tried another stream and only the first one worked on that (rtmp://183.111.26.18:1935/hotter1/definst/111634541-flash-hd-rtmp).
workround:Use the original way to get broadcast ID.
import re
from livestreamer.plugin import Plugin
from livestreamer.stream import HLSStream
from livestreamer.utils import urlget
USER_AGENT = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
HEADERS = {"User-Agent": USER_AGENT}
PLAYLIST_URL = "http://m.afreeca.com/live/stream/a/hls/broad_no/{0}"
CHANNEL_URL = "http://live.afreeca.com:8079/app/index.cgi"
CHANNEL_REGEX = "http(s)?://(\w+\.)?afreeca.com/(?P<username>\w+)"
class AfreecaTV(Plugin):
@classmethod
def can_handle_url(self, url):
return re.match(CHANNEL_REGEX, url)
def _find_broadcast(self, username):
res = urlget(CHANNEL_URL, headers=HEADERS,
params=dict(szBjId=username))
match = re.search(r"<img id=\"broadImg\" src=\".+\/(\d+)\.gif\"",
res.text)
if match:
return match.group(1)
def _get_streams(self):
match = re.match(CHANNEL_REGEX, self.url)
if not match:
return
username = match.group("username")
broadcast = self._find_broadcast(username)
if not broadcast:
return
stream = HLSStream(self.session, PLAYLIST_URL.format(broadcast), headers=HEADERS)
return dict(live=stream)
__plugin__ = AfreecaTV
It works! Thank you!
Please fix it.