1 | diff -crN --exclude=.svn -x data /usr/src/myth/trunk/mythplugins/mythweb/classes/Video.php ./classes/Video.php |
---|
2 | *** /usr/src/myth/trunk/mythplugins/mythweb/classes/Video.php 2010-01-13 14:37:23.000000000 +0000 |
---|
3 | --- ./classes/Video.php 2010-01-20 15:24:52.000000000 +0000 |
---|
4 | *************** |
---|
5 | *** 33,38 **** |
---|
6 | --- 33,46 ---- |
---|
7 | function __construct($intid) { |
---|
8 | global $db; |
---|
9 | global $mythvideo_dir; |
---|
10 | + |
---|
11 | + // Video storage directories |
---|
12 | + $video_dirs = $db->query_list(' |
---|
13 | + SELECT dirname |
---|
14 | + FROM storagegroup |
---|
15 | + WHERE groupname="Coverart" |
---|
16 | + '); |
---|
17 | + |
---|
18 | $video = $db->query_assoc(' |
---|
19 | SELECT * |
---|
20 | FROM videometadata |
---|
21 | *************** |
---|
22 | *** 56,70 **** |
---|
23 | $this->cover_file = $video['coverfile']; |
---|
24 | $this->browse = $video['browse']; |
---|
25 | // And the artwork URL |
---|
26 | ! if ($this->cover_file != 'No Cover' && file_exists($this->cover_file) ) { |
---|
27 | ! $this->cover_url = 'data/video_covers/'.substr($this->cover_file, strlen(setting('VideoArtworkDir', hostname))); |
---|
28 | ! list($width, $height) = @getimagesize($this->cover_file); |
---|
29 | ! if ($width > 0 && $height > 0) { |
---|
30 | ! $wscale = video_img_width / $width; |
---|
31 | ! $hscale = video_img_height / $height; |
---|
32 | ! $scale = $wscale < $hscale ? $wscale : $hscale; |
---|
33 | ! $this->cover_scaled_width = floor($width * $scale); |
---|
34 | ! $this->cover_scaled_height = floor($height * $scale); |
---|
35 | } |
---|
36 | } |
---|
37 | $this->childid = $video['childid']; |
---|
38 | --- 64,90 ---- |
---|
39 | $this->cover_file = $video['coverfile']; |
---|
40 | $this->browse = $video['browse']; |
---|
41 | // And the artwork URL |
---|
42 | ! $this->cover_url = ''; |
---|
43 | ! if ($this->cover_file != 'No Cover') { |
---|
44 | ! $exists = false; |
---|
45 | ! foreach ($video_dirs as $dir) { |
---|
46 | ! $path = preg_replace('#/+#', '/', "$dir/$this->cover_file"); |
---|
47 | ! if (file_exists($path) && is_executable(dirname($path))) { |
---|
48 | ! $exists = true; |
---|
49 | ! break; |
---|
50 | ! } |
---|
51 | ! } |
---|
52 | ! if ($exists) { |
---|
53 | ! $this->cover_url = 'pl/coverart/'.$this->cover_file; |
---|
54 | ! $this->cover_file = path; |
---|
55 | ! list($width, $height) = @getimagesize($this->cover_file); |
---|
56 | ! if ($width > 0 && $height > 0) { |
---|
57 | ! $wscale = video_img_width / $width; |
---|
58 | ! $hscale = video_img_height / $height; |
---|
59 | ! $scale = $wscale < $hscale ? $wscale : $hscale; |
---|
60 | ! $this->cover_scaled_width = floor($width * $scale); |
---|
61 | ! $this->cover_scaled_height = floor($height * $scale); |
---|
62 | ! } |
---|
63 | } |
---|
64 | } |
---|
65 | $this->childid = $video['childid']; |
---|
66 | *************** |
---|
67 | *** 165,167 **** |
---|
68 | --- 185,188 ---- |
---|
69 | |
---|
70 | } |
---|
71 | } |
---|
72 | + ?> |
---|
73 | diff -crN --exclude=.svn -x data /usr/src/myth/trunk/mythplugins/mythweb/modules/coverart/handler.pl ./modules/coverart/handler.pl |
---|
74 | *** /usr/src/myth/trunk/mythplugins/mythweb/modules/coverart/handler.pl 1970-01-01 01:00:00.000000000 +0100 |
---|
75 | --- ./modules/coverart/handler.pl 2010-01-20 09:13:09.000000000 +0000 |
---|
76 | *************** |
---|
77 | *** 0 **** |
---|
78 | --- 1,163 ---- |
---|
79 | + #!/usr/bin/perl |
---|
80 | + # |
---|
81 | + # MythWeb Coverart/Download module |
---|
82 | + # |
---|
83 | + # @url $URL$ |
---|
84 | + # @date $Date$ |
---|
85 | + # @version $Revision$ |
---|
86 | + # @author $Author$ |
---|
87 | + # |
---|
88 | + |
---|
89 | + # Necessary constants for sysopen |
---|
90 | + use Fcntl; |
---|
91 | + |
---|
92 | + # Other includes |
---|
93 | + use Sys::Hostname; |
---|
94 | + use HTTP::Date; |
---|
95 | + |
---|
96 | + # Attempt to use the perl bindings to prevent the backend from shutting down during streaming |
---|
97 | + eval 'use MythTV;'; |
---|
98 | + |
---|
99 | + if (!$@) { |
---|
100 | + our $mythbackend = new MythTV(); |
---|
101 | + $mythbackend->backend_command('ANN Playback '.hostname); |
---|
102 | + } |
---|
103 | + |
---|
104 | + # Which cover are we displaying |
---|
105 | + our $cover = url_param('cover'); |
---|
106 | + if ($Path[1]) { |
---|
107 | + $cover = $Path[1]; |
---|
108 | + } |
---|
109 | + |
---|
110 | + # No match? |
---|
111 | + unless ($cover =~ /\w/) { |
---|
112 | + print header(), |
---|
113 | + "Unknown cover requested.\n"; |
---|
114 | + exit; |
---|
115 | + } |
---|
116 | + |
---|
117 | + # Find the local file |
---|
118 | + our $filename; |
---|
119 | + $sh = $dbh->prepare('SELECT dirname FROM storagegroup WHERE groupname = "Coverart"'); |
---|
120 | + $sh->execute(); |
---|
121 | + while (my ($coverart_dir) = $sh->fetchrow_array()) { |
---|
122 | + next unless (-e "$coverart_dir/$cover"); |
---|
123 | + $filename = "$coverart_dir/$cover"; |
---|
124 | + last; |
---|
125 | + } |
---|
126 | + $sh->finish; |
---|
127 | + |
---|
128 | + 1; |
---|
129 | + |
---|
130 | + unless ($filename) { |
---|
131 | + print header(), |
---|
132 | + "$cover does not exist in any recognized storage group directories for this host."; |
---|
133 | + exit; |
---|
134 | + } |
---|
135 | + |
---|
136 | + # File size |
---|
137 | + my $size = -s $filename; |
---|
138 | + |
---|
139 | + # Zero bytes? |
---|
140 | + if ($size < 1) { |
---|
141 | + print header(), |
---|
142 | + "$cover is an empty file."; |
---|
143 | + exit; |
---|
144 | + } |
---|
145 | + |
---|
146 | + # File type |
---|
147 | + my $type = 'text/html'; |
---|
148 | + my $suffix = ''; |
---|
149 | + if ($cover =~ /\.jpg$/) { |
---|
150 | + $type = 'image/jpeg'; |
---|
151 | + $suffix = '.jpg'; |
---|
152 | + } |
---|
153 | + else { |
---|
154 | + print header(), |
---|
155 | + "Unknown image type requested: $cover\n"; |
---|
156 | + exit; |
---|
157 | + } |
---|
158 | + |
---|
159 | + # Open the file for reading |
---|
160 | + unless (sysopen DATA, $filename, O_RDONLY) { |
---|
161 | + print header(), |
---|
162 | + "Can't read $cover: $!"; |
---|
163 | + exit; |
---|
164 | + } |
---|
165 | + |
---|
166 | + # Binmode, in case someone is running this from Windows. |
---|
167 | + binmode DATA; |
---|
168 | + |
---|
169 | + my $start = 0; |
---|
170 | + my $end = $size; |
---|
171 | + my $total_size = $size; |
---|
172 | + my $read_size = 1024; |
---|
173 | + my $mtime = (stat($filename))[9]; |
---|
174 | + |
---|
175 | + # Handle cache hits/misses |
---|
176 | + if ( $ENV{'HTTP_IF_MODIFIED_SINCE'}) { |
---|
177 | + my $check_time = str2time($ENV{'HTTP_IF_MODIFIED_SINCE'}); |
---|
178 | + if ($mtime <= $check_time) { |
---|
179 | + print header(-Content_type => $type, |
---|
180 | + -status => "304 Not Modified" |
---|
181 | + ); |
---|
182 | + exit; |
---|
183 | + } |
---|
184 | + } |
---|
185 | + |
---|
186 | + # Requested a range? |
---|
187 | + if ($ENV{'HTTP_RANGE'}) { |
---|
188 | + # Figure out the size of the requested chunk |
---|
189 | + ($start, $end) = $ENV{'HTTP_RANGE'} =~ /bytes\W+(\d*)-(\d*)\W*$/; |
---|
190 | + if ($end < 1 || $end > $size) { |
---|
191 | + $end = $size; |
---|
192 | + } |
---|
193 | + $size = $end - $start+1; |
---|
194 | + if ($read_size > $size) { |
---|
195 | + $read_size = $size; |
---|
196 | + } |
---|
197 | + print header(-status => "206 Partial Content", |
---|
198 | + -type => $type, |
---|
199 | + -Content_length => $size, |
---|
200 | + -Accept_Ranges => 'bytes', |
---|
201 | + -Content_Range => "bytes $start-$end/$total_size", |
---|
202 | + -Last_Modified => time2str($mtime), |
---|
203 | + -Content_disposition => " attachment; filename=\"$cover\"" |
---|
204 | + ); |
---|
205 | + } |
---|
206 | + else { |
---|
207 | + print header(-type => $type, |
---|
208 | + -Content_length => $size, |
---|
209 | + -Accept_Ranges => 'bytes', |
---|
210 | + -Last_Modified => time2str($mtime), |
---|
211 | + -Content_disposition => " attachment; filename=\"$cover\"" |
---|
212 | + ); |
---|
213 | + } |
---|
214 | + |
---|
215 | + # Seek to the requested position |
---|
216 | + sysseek DATA, $start, 0; |
---|
217 | + |
---|
218 | + # Print the content to the browser |
---|
219 | + my $buffer; |
---|
220 | + while (sysread DATA, $buffer, $read_size ) { |
---|
221 | + print $buffer; |
---|
222 | + $size -= $read_size; |
---|
223 | + if ($size == 0) { |
---|
224 | + last; |
---|
225 | + } |
---|
226 | + if ($size < $read_size) { |
---|
227 | + $read_size = $size; |
---|
228 | + } |
---|
229 | + } |
---|
230 | + close DATA; |
---|
231 | + |
---|
232 | + # Escape a parameter for safe use in a commandline call |
---|
233 | + sub shell_escape { |
---|
234 | + $str = shift; |
---|
235 | + $str =~ s/'/'\\''/sg; |
---|
236 | + return "'$str'"; |
---|
237 | + } |
---|
238 | + |
---|
239 | + # Return true |
---|
240 | + 1; |
---|
241 | + |
---|
242 | diff -crN --exclude=.svn -x data /usr/src/myth/trunk/mythplugins/mythweb/modules/coverart/init.php ./modules/coverart/init.php |
---|
243 | *** /usr/src/myth/trunk/mythplugins/mythweb/modules/coverart/init.php 1970-01-01 01:00:00.000000000 +0100 |
---|
244 | --- ./modules/coverart/init.php 2010-01-20 09:17:04.000000000 +0000 |
---|
245 | *************** |
---|
246 | *** 0 **** |
---|
247 | --- 1,15 ---- |
---|
248 | + <?php |
---|
249 | + /** |
---|
250 | + * Initialization routines for the MythWeb Video Coverart module |
---|
251 | + * |
---|
252 | + * @url $URL$ |
---|
253 | + * @date $Date$ |
---|
254 | + * @version $Revision$ |
---|
255 | + * @author $Author$ |
---|
256 | + * @license GPL |
---|
257 | + * |
---|
258 | + * @package MythWeb |
---|
259 | + * @subpackage Video Coverart |
---|
260 | + * |
---|
261 | + /**/ |
---|
262 | + ?> |
---|
263 | diff -crN --exclude=.svn -x data /usr/src/myth/trunk/mythplugins/mythweb/modules/video/tmpl/default/video.php ./modules/video/tmpl/default/video.php |
---|
264 | *** /usr/src/myth/trunk/mythplugins/mythweb/modules/video/tmpl/default/video.php 2010-01-13 14:37:22.000000000 +0000 |
---|
265 | --- ./modules/video/tmpl/default/video.php 2010-01-19 15:43:20.000000000 +0000 |
---|
266 | *************** |
---|
267 | *** 318,324 **** |
---|
268 | if (strlen($video->subtitle) > 0) |
---|
269 | echo '<br>' . html_entities($video->subtitle); |
---|
270 | ?></div> |
---|
271 | ! <div id="<?php echo $video->intid; ?>_img"> <img <?php if ($_SESSION["show_video_covers"] && file_exists($video->cover_file)) echo 'src="'.$video->cover_url.'"'; echo ' width="'.$video->cover_scaled_width.'" height="'.$video->cover_scaled_height.'"'; ?> alt="<?php echo t('Missing Cover'); ?>"></div> |
---|
272 | <div id="<?php echo $video->intid; ?>-category"> <?php echo $Category_String[$video->category]; ?></div> |
---|
273 | <div id="<?php echo $video->intid; ?>_playtime"> <?php echo nice_length($video->length * 60); ?></div> |
---|
274 | <div id="<?php echo $video->intid; ?>_imdb"> <?php if ($video->inetref != '00000000') { ?><a href="<?php echo makeImdbWebUrl($video->inetref); ?>"><?php echo $video->inetref ?></a><?php } ?></div> |
---|
275 | --- 318,324 ---- |
---|
276 | if (strlen($video->subtitle) > 0) |
---|
277 | echo '<br>' . html_entities($video->subtitle); |
---|
278 | ?></div> |
---|
279 | ! <div id="<?php echo $video->intid; ?>_img"> <img <?php if ($_SESSION["show_video_covers"] && (strcmp($video->cover_url, '') != 0)) echo 'src="'.$video->cover_url.'"'; echo ' width="'.$video->cover_scaled_width.'" height="'.$video->cover_scaled_height.'"'; ?> alt="<?php echo t('Missing Cover'); ?>"></div> |
---|
280 | <div id="<?php echo $video->intid; ?>-category"> <?php echo $Category_String[$video->category]; ?></div> |
---|
281 | <div id="<?php echo $video->intid; ?>_playtime"> <?php echo nice_length($video->length * 60); ?></div> |
---|
282 | <div id="<?php echo $video->intid; ?>_imdb"> <?php if ($video->inetref != '00000000') { ?><a href="<?php echo makeImdbWebUrl($video->inetref); ?>"><?php echo $video->inetref ?></a><?php } ?></div> |
---|