Update Twitch embedding.
This commit is contained in:
parent
2307de39a7
commit
ba784d5403
@ -57,7 +57,7 @@ Embedding =
|
|||||||
$.on embed, 'click', Embedding.cb.toggle
|
$.on embed, 'click', Embedding.cb.toggle
|
||||||
$.after link, [$.tn(' '), embed]
|
$.after link, [$.tn(' '), embed]
|
||||||
|
|
||||||
if Conf['Auto-embed'] and !Conf['Floating Embeds'] and !post.isFetchedQuote and key isnt 'TwitchTV' # XXX https://github.com/justintv/Twitch-API/issues/289
|
if Conf['Auto-embed'] and !Conf['Floating Embeds'] and !post.isFetchedQuote
|
||||||
$.asap (-> doc.contains embed), ->
|
$.asap (-> doc.contains embed), ->
|
||||||
Embedding.cb.toggle.call embed
|
Embedding.cb.toggle.call embed
|
||||||
|
|
||||||
@ -257,26 +257,16 @@ Embedding =
|
|||||||
src: "//strawpoll.me/embed_1/#{a.dataset.uid}"
|
src: "//strawpoll.me/embed_1/#{a.dataset.uid}"
|
||||||
,
|
,
|
||||||
key: 'TwitchTV'
|
key: 'TwitchTV'
|
||||||
regExp: /^\w+:\/\/(?:www\.)?twitch\.tv\/(\w[^#\&\?]*)/
|
regExp: /^\w+:\/\/(?:www\.|secure\.)?twitch\.tv\/(\w[^#\&\?]*)/
|
||||||
style: "border: none; width: 620px; height: 378px;"
|
|
||||||
el: (a) ->
|
el: (a) ->
|
||||||
if result = /(\w+)\/([bcv])\/(\d+)/i.exec a.dataset.uid
|
m = a.dataset.uid.match /(\w+)(?:\/v\/(\d+))?/
|
||||||
[_, channel, type, id] = result
|
url = "//player.twitch.tv/?#{if m[2] then "video=v#{m[2]}" else "channel=#{m[1]}"}&autoplay=false"
|
||||||
idprefix = if type is 'b' then 'a' else type
|
if (time = a.dataset.href.match /\bt=(\w+)/)
|
||||||
flashvars = "channel=#{channel}&start_volume=25&auto_play=false&videoId=#{idprefix}#{id}"
|
url += "&time=#{time[1]}"
|
||||||
if start = a.dataset.href.match /\bt=(\w+)/
|
el = $.el 'iframe',
|
||||||
seconds = 0
|
src: url
|
||||||
for part in start[1].match /\d+[hms]/g
|
el.setAttribute "allowfullscreen", "true"
|
||||||
seconds += +part[...-1] * {'h': 3600, 'm': 60, 's': 1}[part[-1..]]
|
el
|
||||||
flashvars += "&initial_time=#{seconds}"
|
|
||||||
else
|
|
||||||
channel = (/(\w+)/.exec a.dataset.uid)[0]
|
|
||||||
flashvars = "channel=#{channel}&start_volume=25&auto_play=false"
|
|
||||||
obj = $.el 'object',
|
|
||||||
data: '//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf'
|
|
||||||
$.extend obj, <%= html('<param name="allowFullScreen" value="true"><param name="flashvars">') %>
|
|
||||||
obj.children[1].value = flashvars
|
|
||||||
obj
|
|
||||||
,
|
,
|
||||||
key: 'Vocaroo'
|
key: 'Vocaroo'
|
||||||
regExp: /^\w+:\/\/(?:www\.)?vocaroo\.com\/i\/(\w+)/
|
regExp: /^\w+:\/\/(?:www\.)?vocaroo\.com\/i\/(\w+)/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user