Handle forwarded errors from noembed.com. #2327
This commit is contained in:
parent
10812c8189
commit
4bb99d90a5
@ -177,12 +177,15 @@ Embedding =
|
|||||||
$.toggleClass @, 'embed-removed'
|
$.toggleClass @, 'embed-removed'
|
||||||
|
|
||||||
title: (req, data) ->
|
title: (req, data) ->
|
||||||
return unless req.status
|
|
||||||
|
|
||||||
{key, uid, options, link, post} = data
|
{key, uid, options, link, post} = data
|
||||||
{status} = req
|
|
||||||
service = Embedding.types[key].title
|
service = Embedding.types[key].title
|
||||||
|
|
||||||
|
{status} = req
|
||||||
|
if status in [200, 304] and service.status
|
||||||
|
status = service.status(req.response)[0]
|
||||||
|
|
||||||
|
return unless status
|
||||||
|
|
||||||
text = "[#{key}] #{switch status
|
text = "[#{key}] #{switch status
|
||||||
when 200, 304
|
when 200, 304
|
||||||
text = service.text req.response, uid
|
text = service.text req.response, uid
|
||||||
@ -507,6 +510,12 @@ Embedding =
|
|||||||
title:
|
title:
|
||||||
api: (uid) -> "https://noembed.com/embed?url=https%3A//www.youtube.com/watch%3Fv%3D#{uid}&format=json"
|
api: (uid) -> "https://noembed.com/embed?url=https%3A//www.youtube.com/watch%3Fv%3D#{uid}&format=json"
|
||||||
text: (_) -> _.title
|
text: (_) -> _.title
|
||||||
|
status: (_) ->
|
||||||
|
if _.error
|
||||||
|
m = _.error.match(/^(\d*)\s*(.*)/)
|
||||||
|
[+m[1], m[2]]
|
||||||
|
else
|
||||||
|
[200, 'OK']
|
||||||
preview:
|
preview:
|
||||||
url: (uid) -> "https://img.youtube.com/vi/#{uid}/0.jpg"
|
url: (uid) -> "https://img.youtube.com/vi/#{uid}/0.jpg"
|
||||||
height: 360
|
height: 360
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user