UNPKG

1.11 kBtext/coffeescriptView Raw
1{ parse } = require 'querystring'
2{ map, object } = require 'underscore'
3{ trim, clean } = require 'underscore.string'
4url = require 'url'
5
6get_youtube_id = ($) ->
7 $('.botonTrailer')
8 .attr('onclick')
9 .match(/\/(.{11})(?:\'|\?)/)[1]
10
11table =
12
13 id: (url) ->
14 trim parse(url.split("?")[1]).clv
15
16 url: (urlv) ->
17 url.parse urlv
18
19 title: ->
20 @('.peliculaTitDir').remove()
21 clean @('.peliculaTitulo').first().text()
22
23 time: ->
24 clean @('#horarios p:first-of-type span:last-of-type').text()
25
26 details: ->
27 trim @('[id=peliculaFicha]').html()
28
29 synopsis: ->
30 $ = this
31 el = $('[id=peliculaSinopsis]')
32 $('p', el).removeAttr('style')
33 el.html()
34
35 img: ->
36 url.parse @('[id=peliculaImagen] img').attr('src')
37
38 youtube: ->
39 id = get_youtube_id(this)
40 "http://www.youtube.com/watch?v=#{id}&iv_load_policy=3" if id
41
42 embed: ->
43 id = get_youtube_id(this)
44 "http://www.youtube.com/embed/#{id}?autoplay=1&iv_load_policy=3" if id
45
46module.exports = ($, url) ->
47 movie = object map table, (fn, key) ->
48 [key, try fn.call $, url]
49 if movie.id then movie else null
\No newline at end of file