Module: Constants

Defined in:
lib/constants/constants.rb

Class Method Summary collapse

Class Method Details

.langObject



96
97
98
# File 'lib/constants/constants.rb', line 96

def self.lang
  FilmAffinity.configuration.language.downcase
end

.query_paramsObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/constants/constants.rb', line 2

def self.query_params
  {
    genre: 'genre=%s&',
    country: 'country=%s&',
    from_year: 'fromyear=%i&',
    to_year: 'toyear=%i&',
    no_doc: 'nodoc&',
    no_tv: 'notvse&'
  }
end

.tag(type) ⇒ Object



91
92
93
94
# File 'lib/constants/constants.rb', line 91

def self.tag(type)
  lang = FilmAffinity.configuration.language.to_sym
  Constants.tags[type][lang]
end

.tagsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/constants/constants.rb', line 21

def self.tags
  {

    title: { EN: '#main-title span',
             ES: '#main-title span'
    },

    year: { EN: 'dd[itemprop="datePublished"]',
            ES: 'dd[itemprop="datePublished"]'
    },

    duration: { EN: 'dd[itemprop="duration"]',
                ES: 'dd[itemprop="duration"]'
    },

    country: { EN: '#country-img',
               ES: '#country-img'
    },

    director: { EN: 'a[itemprop="url"]',
                ES: 'a[itemprop="url"]'
    },

    music: { EN: 'dt:contains("Music")',
             ES: 'dt:contains("Music")'
    },

    company: { EN: 'dt:contains("Producer")',
               ES: 'dt:contains("Productora")'
    },

    script: { EN: 'dt:contains("Screenwriter")',
              ES: 'dt:contains("Guion")'
    },

    photography: { EN: 'dt:contains("Cinematography")',
                   ES: 'dt:contains("Fotografía")'
    },

    cast: { EN: 'span[itemprop="actor"]',
            ES: 'span[itemprop="actor"]'
    },

    cast_each: { EN: 'span[itemprop="name"]',
                 ES: 'span[itemprop="name"]'
    },

    genre: { EN: 'dt:contains("Genre")',
             ES: 'dt:contains("Género")'
    },

    sinopsis: { EN: 'dd[itemprop="description"]',
                ES: 'dd[itemprop="description"]'
    },

    rating: { EN: 'div[itemprop="ratingValue"]',
              ES: 'div[itemprop="ratingValue"]'
    },

    poster: { EN: 'img[itemprop="image"]',
              ES: 'img[itemprop="image"]'
    },

    poster_big: { EN: 'a[class="lightbox"]',
                  ES: 'a[class="lightbox"]'
    }

  }
end

.urlsObject



13
14
15
16
17
18
19
# File 'lib/constants/constants.rb', line 13

def self.urls
  {
    top: "http://www.filmaffinity.com/#{lang}/topgen.php%s",
    search_by_title: "http://www.filmaffinity.com/#{lang}/search.php?stext=%s&stype=title",
    movie: "http://www.filmaffinity.com/#{lang}/film%i.html"
  }
end