Changeset 2803561
- Timestamp:
- 10/24/2022 03:49:41 PM (3 years ago)
- Location:
- bg-rutube-embed
- Files:
-
- 15 added
- 2 edited
-
tags/1.5.1 (added)
-
tags/1.5.1/bg-rutube.php (added)
-
tags/1.5.1/css (added)
-
tags/1.5.1/css/bg_rutube.css (added)
-
tags/1.5.1/css/blank.html (added)
-
tags/1.5.1/css/play.svg (added)
-
tags/1.5.1/inc (added)
-
tags/1.5.1/inc/options.php (added)
-
tags/1.5.1/js (added)
-
tags/1.5.1/js/bg_rutube.js (added)
-
tags/1.5.1/languages (added)
-
tags/1.5.1/languages/bg-rutube-embed-ru_RU.mo (added)
-
tags/1.5.1/languages/bg-rutube-embed-ru_RU.po (added)
-
tags/1.5.1/languages/bg-rutube-embed.pot (added)
-
tags/1.5.1/readme.txt (added)
-
trunk/bg-rutube.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bg-rutube-embed/trunk/bg-rutube.php
r2801917 r2803561 4 4 Plugin URI: http://bogaiskov.ru/plugin-bg-rutube-embed/ 5 5 Description: The plugin is the easiest way to embed RuTube videos in WordPress. 6 Version: 1.5 6 Version: 1.5.1 7 7 Author: VBog 8 8 Author URI: http://bogaiskov.ru … … 39 39 die( 'Sorry, you are not allowed to access this page directly.' ); 40 40 } 41 define('BG_RUTUBE_VERSION', '1.5 ');41 define('BG_RUTUBE_VERSION', '1.5.1'); 42 42 43 43 // Подключаем CSS и JS … … 179 179 $val = get_option('bg_rutube_options'); 180 180 $transient = $val ? $val['transient'] : false; 181 182 while($has_next) { 183 $key='rutube_playlist_'.$playlist_id.'_'.$page; // Проверяем обновления на RuTube раз в час 184 if(false===($json=get_transient($key)) || !$transient) { 185 $url = 'http://rutube.ru/api/playlist/custom/'.$playlist_id.'/videos/?page='.$page; 186 $result = wp_remote_get ($url, 187 [ 188 'timeout' => 5, 189 'httpversion' => '1.1', 190 'user-agent' => 'Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)', 191 ] 192 ); 193 if( is_wp_error( $result ) ) { 194 error_log('Playlist data reading error from '.$playlist_id.' : ('.$result->get_error_code().') '.$result->get_error_message() , 0); 195 break; 196 } elseif( ($errorcode = wp_remote_retrieve_response_code( $result )) === 200 ) { 197 $json = wp_remote_retrieve_body($result); 198 set_transient( $key, $json, HOUR_IN_SECONDS ); 199 } else { 200 error_log($url.'<br>'.'Playlist. Error: '.$errorcode.' - '.wp_remote_retrieve_response_message( $result ) , 0); 201 break; 202 } 203 } 204 $videos = json_decode($json, true); 205 206 $page = $videos['page']; 207 $has_next = $videos['has_next']; 208 foreach($videos['results'] as $videoData) { 209 $track['uuid'] = $videoData['id']; 210 $track['url'] = "https://rutube.ru/video/embed/".$videoData['id']."/"; 211 $track['length'] = $videoData['duration']; 212 $track['artist'] = ""; 213 $track['title'] = $videoData['title']; 214 $track['description'] = $videoData['description']; 215 $track['thumbnail'] = $videoData['thumbnail_url']; 216 $tracks[] = $track; 217 } 218 $page++; 219 } 220 if (!empty($tracks)) { 181 $singular = $val ? $val['singular'] : false; 182 183 if (is_singular() || !$singular) { 184 while($has_next) { 185 $key='rutube_playlist_'.$playlist_id.'_'.$page; // Проверяем обновления на RuTube раз в час 186 if(false===($json=get_transient($key)) || !$transient) { 187 $url = 'http://rutube.ru/api/playlist/custom/'.$playlist_id.'/videos/?page='.$page; 188 $result = wp_remote_get ($url, 189 [ 190 'timeout' => 5, 191 'httpversion' => '1.1', 192 'user-agent' => 'Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)', 193 ] 194 ); 195 if( is_wp_error( $result ) ) { 196 error_log('Playlist data reading error from '.$playlist_id.' : ('.$result->get_error_code().') '.$result->get_error_message() , 0); 197 break; 198 } elseif( ($errorcode = wp_remote_retrieve_response_code( $result )) === 200 ) { 199 $json = wp_remote_retrieve_body($result); 200 set_transient( $key, $json, HOUR_IN_SECONDS ); 201 } else { 202 error_log($url.'<br>'.'Playlist. Error: '.$errorcode.' - '.wp_remote_retrieve_response_message( $result ) , 0); 203 break; 204 } 205 } 206 $videos = json_decode($json, true); 207 208 $page = $videos['page']; 209 $has_next = $videos['has_next']; 210 foreach($videos['results'] as $videoData) { 211 $track['uuid'] = $videoData['id']; 212 $track['url'] = "https://rutube.ru/video/embed/".$videoData['id']."/"; 213 $track['length'] = $videoData['duration']; 214 $track['artist'] = ""; 215 $track['title'] = $videoData['title']; 216 $track['description'] = $videoData['description']; 217 $track['thumbnail'] = $videoData['thumbnail_url']; 218 $tracks[] = $track; 219 } 220 $page++; 221 } 222 if (!empty($tracks)) { 223 $info = bg_rutube_get_playlist_info ( $playlist_id ); 224 $playlist['title'] = $info['title']; 225 $playlist['description'] = $info['description']; 226 $playlist['thumbnail'] = $info['thumbnail_url']; 227 $playlist['count'] = $info['videos_count']; 228 $playlist['tracks'] = $tracks; 229 230 if (!$playlist['description']) $playlist['description'] = $playlist['title']; 231 } 232 } else { 221 233 $info = bg_rutube_get_playlist_info ( $playlist_id ); 222 234 $playlist['title'] = $info['title']; 223 235 $playlist['description'] = $info['description']; 224 236 $playlist['thumbnail'] = $info['thumbnail_url']; 225 $playlist['count'] = $info['videos_count'];; 226 $playlist['tracks'] = $tracks; 227 228 if (!$playlist['description']) $playlist['description'] = $playlist['title']; 237 $playlist['count'] = $info['videos_count']; 238 if (!$playlist['description']) $playlist['description'] = $playlist['title']; 229 239 } 230 240 return $playlist; … … 243 253 $val = get_option('bg_rutube_options'); 244 254 $transient = $val ? $val['transient'] : false; 245 246 foreach ($videoList as $videoID) { 247 $videoID = strip_tags($videoID); 248 $videoID = trim($videoID); 249 $key='rutube_'.$videoID; // Проверяем обновления на RuTube раз в час 250 if(false===($json=get_transient($key)) || !$transient) { 251 $url = 'https://rutube.ru/api/video/'.$videoID; 252 $result = wp_remote_get ($url, 253 [ 254 'timeout' => 5, 255 'httpversion' => '1.1', 256 'user-agent' => 'Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)', 257 ] 258 ); 259 $json = ''; 260 if( is_wp_error( $result ) ) { 261 error_log('Metadata reading error from '.$videoID.' : ('.$result->get_error_code().') '.$result->get_error_message() , 0); 262 } elseif( ($errorcode = wp_remote_retrieve_response_code( $result )) === 200 ) { 263 $json = wp_remote_retrieve_body($result); 264 set_transient( $key, $json, HOUR_IN_SECONDS ); 255 $singular = $val ? $val['singular'] : false; 256 257 if (is_singular() || !$singular) { 258 foreach ($videoList as $videoID) { 259 $videoID = strip_tags($videoID); 260 $videoID = trim($videoID); 261 $key='rutube_'.$videoID; // Проверяем обновления на RuTube раз в час 262 if(false===($json=get_transient($key)) || !$transient) { 263 $url = 'https://rutube.ru/api/video/'.$videoID; 264 $result = wp_remote_get ($url, 265 [ 266 'timeout' => 5, 267 'httpversion' => '1.1', 268 'user-agent' => 'Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)', 269 ] 270 ); 271 $json = ''; 272 if( is_wp_error( $result ) ) { 273 error_log('Metadata reading error from '.$videoID.' : ('.$result->get_error_code().') '.$result->get_error_message() , 0); 274 } elseif( ($errorcode = wp_remote_retrieve_response_code( $result )) === 200 ) { 275 $json = wp_remote_retrieve_body($result); 276 set_transient( $key, $json, HOUR_IN_SECONDS ); 277 } else { 278 error_log($url.'<br>'.'Metadata. Error: '.$errorcode.' - '.wp_remote_retrieve_response_message( $result ) , 0); 279 } 280 } 281 $videoData = json_decode($json, true); 282 283 if ($videoData) { 284 $track['uuid'] = $videoID; 285 $track['url'] = "https://rutube.ru/video/embed/".$videoID."/"; 286 $track['length'] = $videoData['duration']; 287 $track['artist'] = ""; 288 $track['title'] = $videoData['title']; 289 $track['description'] = $videoData['description']; 290 $track['thumbnail'] = $videoData['thumbnail_url']; 291 $tracks[] = $track; 265 292 } else { 266 error_log($url.'<br>'.'Metadata. Error: '.$errorcode.' - '.wp_remote_retrieve_response_message( $result ) , 0); 267 } 293 error_log("Metadata. Empty or error answer from RuTube: ". $json." for ".$videoID, 0); 294 } 295 } 296 if (!empty($tracks)) { 297 $playlist['thumbnail'] = $tracks[0]['thumbnail']; 298 $playlist['tracks'] = $tracks; 299 $playlist['count'] = count($tracks); 300 301 if ($playlist['count'] == 1) { 302 $playlist['title'] = trim($tracks[0]['title']); 303 $playlist['description'] = trim($tracks[0]['description']); 304 $playlist['count'] = ""; 305 } else { 306 $playlist['title'] = $title; 307 $playlist['description'] = $description; 308 } 309 310 if (!$playlist['description']) $playlist['description'] = $playlist['title']; 311 } 312 } else { 313 $url = 'https://rutube.ru/api/video/'.$videoList[0]; 314 $result = wp_remote_get ($url, 315 [ 316 'timeout' => 5, 317 'httpversion' => '1.1', 318 'user-agent' => 'Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)', 319 ] 320 ); 321 $json = ''; 322 if( is_wp_error( $result ) ) { 323 error_log('Metadata reading error from '.$videoList[0].' : ('.$result->get_error_code().') '.$result->get_error_message() , 0); 324 } elseif( ($errorcode = wp_remote_retrieve_response_code( $result )) === 200 ) { 325 $json = wp_remote_retrieve_body($result); 326 } else { 327 error_log($url.'<br>'.'Metadata. Error: '.$errorcode.' - '.wp_remote_retrieve_response_message( $result ) , 0); 268 328 } 269 329 $videoData = json_decode($json, true); 270 271 330 if ($videoData) { 272 $track['uuid'] = $videoID; 273 $track['url'] = "https://rutube.ru/video/embed/".$videoID."/"; 274 $track['length'] = $videoData['duration']; 275 $track['artist'] = ""; 276 $track['title'] = $videoData['title']; 277 $track['description'] = $videoData['description']; 278 $track['thumbnail'] = $videoData['thumbnail_url']; 279 $tracks[] = $track; 331 $playlist['thumbnail'] = $videoData['thumbnail_url']; 332 $playlist['count'] = count($videoList); 333 if ($playlist['count'] == 1) { 334 $playlist['title'] = trim($videoData['title']); 335 $playlist['description'] = trim($videoData['description']); 336 $playlist['count'] = ""; 337 } else { 338 $playlist['title'] = $title; 339 $playlist['description'] = $description; 340 } 341 if (!$playlist['description']) $playlist['description'] = $playlist['title']; 280 342 } else { 281 error_log("Metadata. Empty or error answer from RuTube: ". $json." for ".$videoID, 0); 282 } 283 } 284 if (!empty($tracks)) { 285 $playlist['thumbnail'] = $tracks[0]['thumbnail']; 286 $playlist['tracks'] = $tracks; 287 $playlist['count'] = count($tracks); 288 289 if ($playlist['count'] == 1) { 290 $playlist['title'] = trim($tracks[0]['title']); 291 $playlist['description'] = trim($tracks[0]['description']); 292 $playlist['count'] = ""; 293 } else { 294 $playlist['title'] = $title; 295 $playlist['description'] = $description; 296 } 297 298 if (!$playlist['description']) $playlist['description'] = $playlist['title']; 343 error_log("Metadata. Empty or error answer from RuTube: ". $json." for ".$videoList[0], 0); 344 } 345 299 346 } 300 347 return $playlist; -
bg-rutube-embed/trunk/readme.txt
r2801948 r2803561 7 7 Requires at least: 3.0.1 8 8 Tested up to: 6.0.3 9 Stable tag: 1.5 9 Stable tag: 1.5.1 10 10 License: GPLv2 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 49 49 50 50 == Changelog == 51 52 = 1.5.1 = 53 54 * Performance has been improved. 51 55 52 56 = 1.5 =
Note: See TracChangeset
for help on using the changeset viewer.