summaryrefslogtreecommitdiff
path: root/imdb-lookup/index.jinja2.html
blob: 23e75fc5b5383217303cf084f7dec0b467e506eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>{{title}}</title>
  <style>
  .box {
   margin: 20px 50px auto;
   border-radius: 5px;
   box-shadow: 0px 0px 15px 0px gray;
   background-color: #fafafa;
   clear: both;
   position: relative;
  }
  .error {
    background-color: #EFAAAA;
    height: 150px;
  }
  .td1, .td2, .td3, .td4, .td5 {
   width: 1em;
   font-size: 16pt;
   margin: 2px;
   vertical-align: top;
  }
  .td1 .on { color: rgba(0,0,0,0); }
  .td2 .on { color: blue; }
  .td3 .on { color: rgba(0,0,0,0); }
  .td4 .on { color: black; }
  .td1 .off, .td2 .off, .td4 .off, .td5 .off{ color: #c0c0c0; }
  .off div {
   opacity: 0.1;
  }
  .imdb {
   background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABWklEQVQ4y6VTu0oDQRQ9uxslARM3SSGkEbLtNpLGRyeW/oP6ARYWoq34ATaLP2AVsRS7iE0QhNgYSCCRaKGCCIYksM/JtZidNZvd4CMHhjMM99x77swd6fZcJUyBRN9JY6oEALC6NhscMOazy9nzfHa/RZ7Dudl2eII44U9iES8NOhr9pWqk0OFulgBQ2SgQAFIzMr0/aASAAJBxvBDsS3qSGpUiAaD2jUaNSpHk8Uvp9oZottzIZZWNAmp1C6dnnwAAl/HHSwi7AmpGxs7eG9SMjG5vGJyX9FQo7ujkA60nBxEH+ayCx2cX+awS+2yi99y8glrdiiZYXkqFmPkOhWWBjZU5AIDMxtrNqUqIBe7urVhHEQeb62loizORwK39V5T0ZFB5++CFz0GnqtFob8Iqs6WR6aTQLAjYJiBfXPUnihmjWLFt8lVtDPgo/7aqbU74TJfXg3//xi8q0rI5o/Rj/gAAAABJRU5ErkJggg==) no-repeat center;
  }
  .tomato {
   background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACd0lEQVQ4y4WTS0iUYRSGn/+fcUQdzZwZRnDUmsYLUUQXaooC29uiaFVUFLQLXGSSRJtoJ102rSKiWtSmC7SLLi4iUhdBhKBoVmqW02/jODPOzPd/32nhrWiyszrn5ZyXc3kPrGJbu+Id/MfsYmD8WKsF4M+qSwfObY2vRuApBm5rX39056HoLTM8G6pcVxmN7qurHuqdHCiWay054c211O8N1YUrfc9qass2Dg3nTNXgD7va76O6LZwPOoWrnXcTN4NTH8eKEgDcObm983nU1yOlNqbUQ85xCTWVEXw3R1nK5X2Djy1z8vBCT99hJxIjMDGyQtC7pfn6dIXdcWDKxecVjnc30PRqhs+tFRDycePiODbwotbGCZT0HX85GAewnEgMYJcNb03Yw/NmH08aS6nHors/DZ8U50+HOfIgwSbHLCxOQFucAm5bAE4k9pRyq93T4qO8sQJvqBylNLnJDHp0noGcgAU7Jt3fJ3YCEyNBLwBCO+UWVqWXQrAMWsKYZBY7qxB/nt3jBcZKVyoFUEgAwLuMasAVUBqdzCLzCpRGtKCASFqW03IipGQh9i7e4g0Z2WNmXKyvWWTeXSCaziM/DShBgDxCRoSfxpARowG8CdYAXKEge8wXhSjB9ucRDeK4yHeNArIipMQwYwzftUK0exnA0un+Eo9/p3IisVdAG7KoDllsF2EOIWk0Ca355uZJF/LjnelUA4C9WExgYmQ/8BhrYUk5S0hi+GY0465itJDnQyZFIpt5dzYUi96vqvlTiUvKSkRi8XmRrlkxB6eNJqEVSaVIqtxrv1jXzmTnHt2pquFEaqb4d03Ubfjn592rWvsX9guv1i7Q6dsNWAAAAABJRU5ErkJggg==) no-repeat center;
  }
  .poster {
   margin: 10px;
   width: 154px;
   float: left;
   min-height: 200px;
   box-shadow: 0px 0px 5px 0px gray;
  }
  .info {
   padding-left: 5px;
   vertical-align: top;
  }
  .info table td { padding: .2em; }
  .details { padding: 0.5em; }
  .files {
    list-style: none;
    padding-left: 0px;
    font-size: 0.7em;
    margin: 0px;
  }
  .imdbid {
   font-family: monospace;
   padding: 3px; 
   background-color: #f0f0f0; 
   border: 1px solid #e0e0e0; 
   border-radius: 4px;
  }
  .title { font-size: 2em; }
  .headline { font-size: 0.9em; color: 3e3e3e; }
  .plot { margin-top: 10px; }
  .box-footer {
   position: absolute;
   bottom: 0px;
   right: 0px;
   font-size: 1.4em;
   color: #ccc;
   font-style: italic;
  }
  .rated {
   border: 1px solid black;
   border-radius: 5px;
   font-size:0.7em;
   padding: 2px;
  }
  </style>
 </head>
 <body>
  {% for (path, imdb_id) in input %}
   {% set info = tmdbcache.infos(imdb_id) %}</h2>
   {% set imdb_data = tmdbcache.imdb_movie(imdb_id)['data'] %}
   {% set omdb_data = tmdbcache.omdb_movie(imdb_id) %}
   {% if info and imdb_data and omdb_data %}
   {% set year = info['release_date'] and int(info['release_date'].split('-')[0]) or gmtime.tm_year %}
   {% set age = gmtime.tm_year - year %}
   {% set centuries = int(age / 10) %}
   {% set posterBase64 = tmdbcache.poster_base64(info['poster_path'],'w154') %}
   {% set local_title = tmdbcache.alternative_title(imdb_id, "DE") %}
   {% set votes = imdb_data['num_votes'] %}
   {% set popularity = int( 9*(1 - (1+math.exp(-1))/(1+math.exp(votes/70000.0 -1 ))) + 1 ) %}
   {% set fresh = (omdb_data.tomatoMeter != 'N/A') and int(omdb_data.tomatoMeter) or None %}
   {% set userMeter = (omdb_data.tomatoUserMeter != 'N/A') and int(omdb_data.tomatoUserMeter) or None %}
   <div class="box">
    <table>
     <tr>
      {% if "vote_average" in info.keys() %}
      <td class="td1" title="IMDB Rating: {{imdb_data.rating}}">
       <span class="off">
        {% for i in range(int(imdb_data.rating),10) %}
        <div class="imdb"></div>
        {% endfor %}
       </span>
       <span class="on">
        {% for i in range(0, int(imdb_data.rating)) %}
        <div class="imdb"></div>
        {% endfor %}
       </span>
      </td>
      {% if userMeter %}
      <td class="td2" title="Rotten tomatoes user rating: {{userMeter}}%">
       <span class="off">{{ " ".join(["☆"] * (10-int(userMeter/10))) }}</span>
       <span class="on">{{ " ".join(["★"] * int(userMeter/10)) }}</span>
      </td>
      {% else %}
      <td class="td2"></td>
      {% endif %}
      {% if fresh %}
      <td class="td3" title="Rotten tomatoes: {{fresh}}% fresh">
       <span class="off">
        {% for i in range(int(fresh/10),10) %}
        <div class="tomato"></div>
        {% endfor %}
       </span>
       <span class="on">
        {% for i in range(0, int(fresh/10)) %}
        <div class="tomato"></div>
        {% endfor %}
       </span>
      </td>
      {% else %}
      <td class="td3"></td>
      {% endif %}
      <td class="td4" title="IMDB Popularity: {{votes}} votes">
      <span class="off">{{ " ".join(["☆"] * (10-popularity)) }}</span>
      <span class="on">{{ " ".join(["★"] * popularity) }}</span>
      </td>
      <td class="td5" title="Centuries since release">
      <span class="off">{{ " ".join(["⌚"] * (9-centuries)) }}</span>
      <span class="on">{{ " ".join(["⌚"] * (centuries + 1)) }}</span>
      </td>
      {% endif %}
      <td class="poster">
       {% if posterBase64 %}
       <a href="{{urlencode(path)}}"><img src="{{ posterBase64 }}" /></a>
       {% else %}
       <span> no image </span>
       {% endif %}
      </td>
      <td class="info">
       <div class="title">
        {{ info.title }}
       </div>
       <div class="headline">
        {% if local_title != info.title %}{{ local_title }}”, {% endif %}
        {% if info.original_title != info.title %}{{ info.original_title }}”, {% endif %}
       </div>
       <div class="headline">
        by {{ imdb_data["directors_summary"] | join(", ", attribute="name.name") }},
        runtime {{ info['runtime'] }} min, {{year}} 
        {% if omdb_data.Rated != 'N/A' %}
        <span class="rated">{{omdb_data.Rated}}</span>
        {% endif %}
       </div>
       <div class="headline">
        Starring: {{ imdb_data["cast_summary"] | join(", ", attribute="name.name") }}
       </div>
       <div class="plot">{{ "plot" in imdb_data and imdb_data.plot.outline or ""}}</div>
       <table class="details">
        {% if 'homepage' in info and info['homepage'] %}
        <tr>
         <td colspan="2"><a href="{{ info['homepage'] }}">{{ info['homepage'] }}</a>
         </td>
        </tr>
        {% elif omdb_data.Website != "N/A" %}
        <tr>
         <td colspan="2"><a href="{{ omdb_data.Website }}">{{ omdb_data.Website }}</a>
         </td>
        </tr>
        {% endif %}
        <tr>
         <td colspan="2"><a href="http://www.themoviedb.org/movie/{{ info.id }}" rel="noreferrer">themoviedb.org</a>
          &ensp;<a href="http://www.imdb.com/title/{{ info.imdb_id }}" rel="noreferrer">imdb.com</a>
          &ensp;<a href="http://letterboxd.com/tmdb/{{ info.id }}" rel="noreferrer">letterboxd.com</a>
          &ensp;<a href="http://www.ofdb.de/view.php?page=suchergebnis&Kat=IMDb&SText={{ info.imdb_id }}" rel="noreferrer">ofdb.db</a>
          &ensp;<span class="imdbid">{{ info.imdb_id }}</span>
         </td>
        </tr>
       </table>   
       <ul class="files">
         {% for file in listMovieFiles(path) %}
         <li>
           {% set pathElements = file.split("/") %}
           {% for i in range(1,pathElements.__len__()) %}<a href="{{urlencode(pathjoin(*pathElements[:i+1]))}}">
             {{ pathElements[i] }}
           </a>
           {% endfor %}
         </li>
         {% endfor %}
       </ul>       
      </td>
     </tr>
    </table>
    <div class="box-footer">
     {{ info.tagline and info.tagline or "" }}
    </div>
   </div>
   {% else %}
   <div class="box error">
       No infos for <a href="{{path}}">{{path}}</a> {{imdb_id}}
   </div>
   {% endif %}
  {% endfor %}
 </body>
</html>
<!--
vim: tabstop=1 expandtab shiftwidth=1 softtabstop=1:
-->