Skip to content

Commit

Permalink
Fixed some more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amix committed May 13, 2014
1 parent f40a08b commit e244b9e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 16 deletions.
41 changes: 34 additions & 7 deletions lib/media-parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 25 additions & 7 deletions src/media_services.coffee
Expand Up @@ -100,7 +100,6 @@ MediaServices = {
match = cnt.match(MediaServices.providers.Yfrog) match = cnt.match(MediaServices.providers.Yfrog)
if match if match
MediaTypes.imageEntity(callback, { MediaTypes.imageEntity(callback, {
'underlying_type': 'image'
'sizes': { 'sizes': {
'small': 100, 'small': 100,
'medium': 640 'medium': 640
Expand Down Expand Up @@ -140,10 +139,24 @@ MediaServices = {


# --- Hulu # --- Hulu
parseHulu: (cnt, callback, timeout) -> parseHulu: (cnt, callback, timeout) ->
return MediaTypes.genericOemebed(cnt, callback, match = cnt.match(MediaServices.providers.Hulu)
MediaServices.providers.Hulu, if match
'http://www.hulu.com/api/oembed?url={0}&format=json', MediaTypes.oembedImageEntitiy(callback, {
timeout, 'video') 'underlying_type': 'video'
'timeout': timeout
'sizes': {
'r': 145,
'l': 512
}
'match': match
'oembed_template': 'http://www.hulu.com/api/oembed?url={0}&format=json'
'custom_thumbnail_url': (turl, best_size, json) ->
if best_size == 'r'
return [json.thumbnail_url, json.thumbnail_width, json.thumbnail_height]
else
return [json.large_thumbnail_url, json.large_thumbnail_width, json.large_thumbnail_height]
})
return true


# --- Justin # --- Justin
parseJustin: (cnt, callback, timeout) -> parseJustin: (cnt, callback, timeout) ->
Expand Down Expand Up @@ -201,7 +214,8 @@ MediaServices = {
'match': match 'match': match
'oembed_template': "http://vimeo.com/api/oembed.json?url={0}" 'oembed_template': "http://vimeo.com/api/oembed.json?url={0}"
'custom_thumbnail_url': (turl, best_size) -> 'custom_thumbnail_url': (turl, best_size) ->
return turl.replace(/_\d+\.jpg$/i, "_" + best_size + ".jpg") size = parseInt(best_size)
return [turl.replace(/_\d+\.jpg$/i, "_" + best_size + ".jpg"), size, size]
}) })
return true return true


Expand All @@ -223,7 +237,11 @@ MediaServices = {
turl = turl.replace(/thumbnail(?:-\d)?\.jpg/, "thumbnail-" + best_size + ".jpg") turl = turl.replace(/thumbnail(?:-\d)?\.jpg/, "thumbnail-" + best_size + ".jpg")
if turl.indexOf('http') != 0 if turl.indexOf('http') != 0
turl = 'http:' + turl turl = 'http:' + turl
return turl if best_size == '3'
size = 240
else
size = 576
return [turl, size, size]
}) })
return true return true


Expand Down
4 changes: 2 additions & 2 deletions src/media_types.coffee
Expand Up @@ -39,8 +39,8 @@ MediaTypes = {
width = opts.sizes[best_size] width = opts.sizes[best_size]
turl = json.thumbnail_url turl = json.thumbnail_url
custom_turl = opts.custom_thumbnail_url(turl, best_size, json) custom_turl = opts.custom_thumbnail_url(turl, best_size, json)
if custom_turl custom_turl[0] = custom_turl[0].replace('http:', 'https:')
return [custom_turl.replace('http:', 'https:'), width] return custom_turl


# Default # Default
turl = json.thumbnail_url turl = json.thumbnail_url
Expand Down

0 comments on commit e244b9e

Please sign in to comment.