Advertisement
Guest User

formatowanie, zmieniono w396 na w200

a guest
Sep 22nd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.12 KB | None | 0 0
  1. <?php
  2. function dbmovies_page()
  3. {
  4. add_menu_page(
  5. __d('Importer tool'),
  6. __d('dbmovies'),
  7. 'manage_options',
  8. 'dbmovies.org',
  9. 'dbmovies_callback',
  10. 'dashicons-networking'
  11. );
  12. }
  13. function dbmovies_callback()
  14. {?>
  15. <div id="dt_importer" class="dt_importer_wrap">
  16. <header class="dt_importer">
  17. <div class="box">
  18. <h1><a href="https://dbmovies.org" target="_blank"><img src="<?php echo DT_DIR_URI; ?>/assets/img/dbmovies.png"></a> <i>by Goldregister</i></h1>
  19. </div>
  20. </header><!-- fin header.dt_importer -->
  21. <div class="dt_importer_contaiter">
  22. <div class="dt_imp_menu">
  23. <ul class="tabs">
  24. <li id="filter_year_li" class="tab-link current" data-tab="tab-1"><?php _d('Filter for year');?></li>
  25. <li id="filter_year_li" class="tab-link" data-tab="tab-0"><?php _d('Search title');?></li>
  26. <li id="single_url_li" class="tab-link" data-tab="tab-2"><?php _d('Import ID');?></li>
  27. <li class="tab-link" data-tab="tab-3"><?php _d('Status');?></li>
  28.  
  29. </ul>
  30. <div id="add_data_post"></div>
  31. </div><!-- fin div.dt_imp_menu -->
  32. <div class="content">
  33. <div id="tab-0" class="tab-content">
  34. <h1 style="margin-top: 0;"><?php _d('Search content');?></h1>
  35. <form id="search_all" class="search_all">
  36. <div class="box">
  37. <input type="text" name="query" placeholder="<?php _d('Search a title..');?>">
  38. <button name="search_all_data" type="submit" class="button button-primary"><?php _d('Search');?></button>
  39. </div>
  40. <label for="page"><input type="number" name="page"></label>
  41. <label for="movie"><input type="radio" id="movie" name="type" value="movie" required checked> <?php _d('Movies');?></label>
  42. <label for="tvshows"><input type="radio" id="tvshows" name="type" value="tv" required> <?php _d('TV Shows');?></label>
  43. <?php wp_nonce_field('search-all', 'search-all-nonce')?>
  44. </form>
  45. </div>
  46. <div id="tab-1" class="tab-content current">
  47. <section style="margin: auto;width: 100%;border: 3px solid red;padding: 10px;">
  48. <h1 style="margin-top: 0;"><?php _d('Movies');?></h1>
  49. <form id="search_imdb" class="form_importer_dt">
  50. <p>
  51. <input type="number" id="imdbyear" name="imdbyear" placeholder="<?php _d('Year');?>" min="1930" max="2019" required>
  52. <input style="margin-right: 0" type="number" id="imdbpage" name="imdbpage" placeholder="<?php _d('Page');?>" min="1" required>
  53. </p>
  54. <p><input type="submit" class="button button-primary" name="search_data_imdb" value="<?php _d('Get content');?>"></p>
  55. <?php wp_nonce_field('send-imdb', 'send-imdb-nonce')?>
  56. </form>
  57. </section>
  58.  
  59. <p class="desc"><?php _d('Get data from Themoviedb.org');?></p>
  60. </div>
  61. <div id="tab-2" class="tab-content">
  62. <section>
  63. <h1 style="margin-top: 0;"><?php _d('Movies');?></h1>
  64. <form id="single_url_imdb" class="form_importer_dt">
  65. <p><input type="text" name="idmovie" placeholder="<?php _d('ID Movie');?>" required></p>
  66. <p><input type="submit" class="button button-primary" name="send_id_movie" value="<?php _d('Import');?>"></p>
  67. <?php wp_nonce_field('send-movies', 'send-movies-nonce')?>
  68. <p class="desc"><?php _d('Example');?>: themoviedb.org/movie/<strong>14564</strong></p>
  69. </form>
  70. </section>
  71.  
  72. <section class="right" style=display:none>
  73.  
  74. </section>
  75. </div>
  76. <div id="tab-3" class="tab-content">
  77. <h1 style="margin-top: 0;"><?php _d('Status of server processes');?></h1>
  78. <div id="result_server"></div>
  79. <form id="api_status" class="form_importer_dt">
  80. <?php wp_nonce_field('send-status', 'send-status-nonce')?>
  81. <p><input type="submit" class="button button-primary" value="<?php _d('Check server status');?>"></p>
  82. </form>
  83. </div>
  84.  
  85. </div><!-- fin div.content -->
  86. <div id="resultado"></div>
  87. <div class="dbmovies_copy">&copy; <?php echo date('Y'); ?> <a href="http://imdbfilm.top" target="_blank">goldregister</a></div>
  88. </div><!-- fin div.dt_importer_contaiter -->
  89. </div><!-- fin div.dt_importer_wrap -->
  90. <?php
  91. // FIN HTML
  92. }
  93.  
  94. /* dbmovies Ajax
  95. -------------------------------------------------------------------------------
  96. */
  97. function dbmovies_assets()
  98. {
  99. if ($_GET['page'] == 'dbmovies.org') {
  100. wp_enqueue_style('dt-importer-tool-styles', DT_DIR_URI . '/css/importer.css', '', DT_VERSION, 'all');
  101. wp_enqueue_script('dt-importer-tool-scripts', DT_DIR_URI . '/js/importer.js', array('jquery'), DT_VERSION, false);
  102. wp_localize_script('dt-importer-tool-scripts', 'DTapi', array(
  103. // Importar
  104. 'ajaxurl' => admin_url('admin-ajax.php', 'relative'),
  105. // Mensajes
  106. 'preresultado' => __d('Searching content, wait a moment...'),
  107. 'preresultadolog' => __d('Searching and extracting data...'),
  108. 'resultadolog' => __d('Data found, completed process!'),
  109. 'resultadoerror' => __d('Error, no data...'),
  110. 'agregandodatos' => __d('Adding data...'),
  111. 'agregandodatoslog' => __d('Adding content to the database...'),
  112. 'procesocompleto' => __d('Process completed!'),
  113. 'postdataerror' => __d('Content could not be added!'),
  114. 'queryserver' => __d('Server status query...'),
  115. 'verificationsr' => __d('Verification completed!'),
  116. 'loading' => __d('Loading...'),
  117. 'getcontent' => __d('Get content'),
  118. ));
  119. }
  120. }
  121.  
  122. /* Search All content
  123. -------------------------------------------------------------------------------
  124. */
  125. function dbm_search_all()
  126. {
  127. if (current_user_can('manage_options')) {
  128. if (isset($_POST['search-all-nonce']) and wp_verify_nonce($_POST['search-all-nonce'], 'search-all')) {
  129. $apikey = tmdbkey;
  130. $apilang = tmdblang;
  131. $query = $_POST['query'];
  132. $page = $_POST['page'];
  133. $type = $_POST['type'];
  134. // Resolver json Search
  135. $api = wp_remote_get(tmdburl . 'search/' . $type . '?api_key=' . $apikey . '&language=' . $apilang . '&query=' . $query . '&page=' . $page);
  136. $json = wp_remote_retrieve_body($api);
  137. $data = json_decode($json, true);
  138.  
  139. // resultados de la API
  140. $pagex = $data['page'];
  141. $total_results = $data['total_results'];
  142. $total_pages = $data['total_pages'];
  143. $results = $data['results'];
  144. $ct = array();
  145. $limit = count($results);
  146. $num = ($limit * $page - $limit + 1);
  147. echo '<div class="dtlist">';
  148. echo '<h1>' . __d('Page') . ' <b>' . $pagex . '</b> ' . __d('of') . ' <b>' . $total_pages . '</b> ' . __d('there are') . ' <b>' . $total_results . '</b> ' . __d('titles found') . '</h1>';
  149. foreach ($results as $ci) {
  150. $id = $ct[] = $ci['id'];
  151. if ($type == 'movie') {
  152. $title = $ct[] = $ci['title'];
  153. $year = $ct[] = substr($ci['release_date'], 0, 4);
  154. $class = 'a_import_imdb';
  155. $meta = 'idtmdb';
  156. } elseif ($type == 'tv') {
  157. $title = $ct[] = $ci['name'];
  158. $year = $ct[] = substr($ci['first_air_date'], 0, 4);
  159. $class = 'a_import_tmdb';
  160. $meta = 'ids';
  161. }
  162. $poster = $ct[] = $ci['poster_path'];
  163. // vericador
  164. global $wpdb;
  165. $consulta = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '$meta' AND meta_value = '{$id}' ";
  166. $verificar = $wpdb->get_results($consulta, OBJECT);
  167.  
  168. echo '<article id="' . $id . '">';
  169. if ($poster) {
  170. echo '<div class="img"><img src="https://image.tmdb.org/t/p/w45' . $poster . '"></div>';
  171. } else {
  172. echo '<div class="no_img"><span class="dashicons dashicons-no"></span></div>';
  173. }
  174. if ($verificar) {
  175. echo $num . ' <span class="imported">' . __d('imported') . '</span> <strong><a href="http://themoviedb.org/' . $type . '/' . $id . '/" target="_blank">' . $title . '</a></strong> <i>(' . $year . ')</i>';
  176. } else {
  177. echo $num . ' <span><a class="' . $class . '" data-id="' . $id . '">' . __d('Import') . '</a></span> <strong><a href="http://themoviedb.org/' . $type . '/' . $id . '" target="_blank">' . $title . '</a></strong> <i>(' . $year . ')</i>';
  178. }
  179. echo '</article>';
  180. $num++;
  181.  
  182. }
  183. echo '</div>';
  184. echo '<a id="load_more_search">' . __d('Next page') . '</a>';
  185.  
  186. }
  187. }
  188. die();
  189. }
  190.  
  191. add_action('wp_ajax_dbm_search_all', 'dbm_search_all');
  192. add_action('wp_ajax_nopriv_dbm_search_all', 'dbm_search_all');
  193.  
  194. /* Get Movies
  195. -------------------------------------------------------------------------------
  196. */
  197. function dbm_get_movies()
  198. {
  199. if (current_user_can('manage_options')) {
  200. if (isset($_POST['send-imdb-nonce']) and wp_verify_nonce($_POST['send-imdb-nonce'], 'send-imdb')) {
  201. // Parametros
  202. $apiyear = $_POST['imdbyear'];
  203. $apipage = $_POST['imdbpage'];
  204. $apikey = tmdbkey;
  205. $apilang = tmdblang;
  206. // Resolver json discover
  207. $api = wp_remote_get(tmdburl . 'discover/movie?api_key=' . $apikey . '&language=' . $apilang . '&sort_by=popularity.desc&page=' . $apipage . '&primary_release_year=' . $apiyear);
  208. $json = wp_remote_retrieve_body($api);
  209. $data = json_decode($json, true);
  210. // resultados de la API
  211. $page = $data['page'];
  212. $total_results = $data['total_results'];
  213. $total_pages = $data['total_pages'];
  214. $results = $data['results'];
  215. $ct = array();
  216. $limit = count($results);
  217. $num = ($limit * $page - $limit + 1);
  218. echo '<h1>' . __d('Page') . ' <b>' . $page . '</b> ' . __d('of') . ' <b>' . $total_pages . '</b> ' . __d('there are') . ' <b>' . $total_results . '</b> ' . __d('titles found') . '</h1>';
  219. echo '<div class="dtlist">';
  220. foreach ($results as $ci) {
  221. $id = $ct[] = $ci['id'];
  222. $title = $ct[] = $ci['title'];
  223. $year = $ct[] = substr($ci['release_date'], 0, 4);
  224. $poster = $ct[] = $ci['poster_path'];
  225. // vericador
  226. global $wpdb;
  227. $consulta = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'idtmdb' AND meta_value = '{$id}' ";
  228. $verificar = $wpdb->get_results($consulta, OBJECT);
  229. echo '<article id="' . $id . '">';
  230. if ($poster) {
  231. echo '<div class="img"><img src="https://image.tmdb.org/t/p/w45' . $poster . '"></div>';
  232. } else {
  233. echo '<div class="no_img"><span class="dashicons dashicons-no"></span></div>';
  234. }
  235. if ($verificar) {
  236. echo $num . ' <span class="imported">' . __d('imported') . '</span> <strong><a href="http://themoviedb.org/movie/' . $id . '/" target="_blank">' . $title . '</a></strong> <i>(' . $year . ')</i>';
  237. } else {
  238. echo $num . ' <span><a class="a_import_imdb" data-id="' . $id . '">' . __d('Import') . '</a></span> <strong><a href="http://themoviedb.org/movie/' . $id . '" target="_blank">' . $title . '</a></strong> <i>(' . $year . ')</i>';
  239. }
  240. echo '</article>';
  241. $num++;
  242. }
  243. echo '</div>';
  244. echo '<a id="load_more_imdb_link">' . __d('Next page') . '</a>';
  245. }
  246. }
  247. die();
  248. }
  249.  
  250. /* Get TV Shows
  251. -------------------------------------------------------------------------------
  252. */
  253. function dbm_get_tv()
  254. {
  255. if (current_user_can('manage_options')) {
  256. if (isset($_POST['send-tmdb-nonce']) and wp_verify_nonce($_POST['send-tmdb-nonce'], 'send-tmdb')) {
  257. // Parametros
  258. $apiyear = $_POST['tmdbyear'];
  259. $apipage = $_POST['tmdbpage'];
  260. $apikey = tmdbkey;
  261. $apilang = tmdblang;
  262. // Resolver json Discover
  263. $api = wp_remote_get(tmdburl . 'discover/tv?api_key=' . $apikey . '&language=' . $apilang . '&sort_by=popularity.desc&first_air_date_year=' . $apiyear . '&page=' . $apipage);
  264. $json = wp_remote_retrieve_body($api);
  265. $data = json_decode($json, true);
  266. // resultados de la API
  267. $page = $data['page'];
  268. $total_results = $data['total_results'];
  269. $total_pages = $data['total_pages'];
  270. $results = $data['results'];
  271. $ct = array();
  272. echo '<h1>' . __d('Page') . ' <b>' . $page . '</b> ' . __d('of') . ' <b>' . $total_pages . '</b> ' . __d('there are') . ' <b>' . $total_results . '</b> ' . __d('titles found') . '</h1>';
  273. echo '<div class="dtlist">';
  274. $limit = count($results);
  275. $num = ($limit * $page - $limit + 1);
  276. // Mostrar resultados
  277. foreach ($results as $ci) {
  278. $id = $ct[] = $ci['id'];
  279. $poster = $ct[] = $ci['poster_path'];
  280. $name = $ct[] = $ci['name'];
  281. $year = $ct[] = substr($ci['first_air_date'], 0, 4);
  282.  
  283. // vericador
  284. global $wpdb;
  285. $consulta = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'ids' AND meta_value = '{$id}' ";
  286. $verificar = $wpdb->get_results($consulta, OBJECT);
  287.  
  288. echo '<article id="' . $id . '">';
  289. if ($poster) {
  290. echo '<div class="img"><img src="https://image.tmdb.org/t/p/w45' . $poster . '"></div>';
  291. } else {
  292. echo '<div class="no_img"><span class="dashicons dashicons-no"></span></div>';
  293. }
  294. if ($verificar) {
  295. echo $num . ' <span class="imported">' . __d('imported') . '</span> <strong>' . $name . '</strong> <i>(' . $year . ')</i>';
  296. } else {
  297. echo $num . ' <span><a class="a_import_tmdb" data-id="' . $id . '">' . __d('Import') . '</a></span> <strong><a href="http://themoviedb.org/tv/' . $id . '/" target="_blank">' . $name . '</a></strong> <i>(' . $year . ')</i>';
  298. }
  299. echo '</article>';
  300. $num++;
  301. }
  302. echo '</div>';
  303. echo '<a id="load_more_tmdb_link">' . __d('Next page') . '</a>';
  304. }
  305. }
  306. die();
  307. }
  308.  
  309. /* dbmovies.org status
  310. -------------------------------------------------------------------------------
  311. */
  312. function dbm_status()
  313. {
  314. if (current_user_can('manage_options')) {
  315. if (isset($_POST['send-status-nonce']) and wp_verify_nonce($_POST['send-status-nonce'], 'send-status')) {
  316. // Resolver json Discover
  317. $api = wp_remote_get(dbmurl . 'status/query');
  318. $json = wp_remote_retrieve_body($api);
  319. $data = json_decode($json, true);
  320. // Resultados
  321. $status = $data['server'];
  322. $dbmovies = $data['dbmovies'];
  323. $imdb = $data['imdbscraper'];
  324. $tmdb = $data['themoviedb'];
  325.  
  326. if ($dbmovies >= '76') {$color = '#da3b3b';}
  327. if ($dbmovies <= '75') {$color = '#f68b1f';}
  328. if ($dbmovies < '50') {$color = '#9bca3e';}
  329. if ($imdb >= '76') {$color1 = '#da3b3b';}
  330. if ($imdb <= '75') {$color1 = '#f68b1f';}
  331. if ($imdb < '50') {$color1 = '#9bca3e';}
  332. if ($tmdb >= '76') {$color2 = '#da3b3b';}
  333. if ($tmdb <= '75') {$color2 = '#f68b1f';}
  334. if ($tmdb < '50') {$color2 = '#9bca3e';}
  335. if ($status == 'online') {
  336. echo '
  337. <div class="skillbar clearfix" data-percent="' . $dbmovies . '%">
  338. <div class="skillbar-title"><span>dbmovies</span></div>
  339. <div class="skillbar-bar" style="background: ' . $color . '"></div>
  340. <div class="skill-bar-percent">' . $dbmovies . '%</div>
  341. </div>
  342.  
  343. <div class="skillbar clearfix" data-percent="' . $imdb . '%">
  344. <div class="skillbar-title"><span>imdbscraper</span></div>
  345. <div class="skillbar-bar" style="background: ' . $color1 . '"></div>
  346. <div class="skill-bar-percent">' . $imdb . '%</div>
  347. </div>
  348.  
  349. <div class="skillbar clearfix" data-percent="' . $tmdb . '%">
  350. <div class="skillbar-title"><span>themoviedb</span></div>
  351. <div class="skillbar-bar" style="background: ' . $color2 . '"></div>
  352. <div class="skill-bar-percent">' . $tmdb . '%</div>
  353. </div>
  354. ';
  355. }
  356. }
  357. }
  358. die();
  359. }
  360.  
  361. /* Post Movies
  362. -------------------------------------------------------------------------------
  363. */
  364. function dbm_post_movie()
  365. {
  366. if (isset($_POST['send-movies-nonce']) and wp_verify_nonce($_POST['send-movies-nonce'], 'send-movies')) {
  367. if (current_user_can('manage_options')) {
  368. $key = tmdbkey;
  369. $lang = tmdblang;
  370. $idmovie = $_POST["idmovie"];
  371. if (($idmovie != null)) {
  372. $api_1 = wp_remote_get(tmdburl . "movie/" . $idmovie . "?append_to_response=images,trailers&language=" . $lang . "&include_image_language=" . $lang . ",null&api_key=" . $key . "");
  373. $json_1 = wp_remote_retrieve_body($api_1);
  374. $data = json_decode($json_1, true);
  375. // ##########################################
  376. $imdb = $data['imdb_id'];
  377. $idtmdb = $data['id'];
  378. $api = wp_remote_get(imdbdata2 . $imdb);
  379. $omdbiurl = "https://www.omdbapi.com/?apikey=c0d64821&i=" . $imdb;
  380. $apiomdapi = wp_remote_get($omdbiurl);
  381. $json_omdb = wp_remote_retrieve_body($apiomdapi);
  382. $data = json_decode($json_1, true);
  383. $data1 = json_decode($json_omdb, true);
  384. // ##########################################
  385. $a4 = $data1['imdbRating'];
  386. $a5 = $data1['imdbVotes'];
  387. $a6 = $data1['Rated'];
  388. $a7 = $data1['Country'];
  389. // ##########################################
  390. $b1 = $data['runtime'];
  391. $b2 = $data['tagline'];
  392. $b3 = $data['title'];
  393. $b4 = $data['overview'];
  394. $b9 = $data['vote_count'];
  395. $b10 = $data['vote_average'];
  396. $b11 = $data['release_date'];
  397. add_post_meta($post_id, "release_date", ($b11), true);
  398.  
  399. $b12 = $data['original_title'];
  400. $a3 = substr($b11, 0, 4);
  401. $b13 = $data['poster_path'];
  402. if ($get_img = $data['poster_path']) {
  403. $upimg = 'https://image.tmdb.org/t/p/w200' . $get_img;
  404. }
  405. $b14 = 'https://image.tmdb.org/t/p/w1280' . $data['backdrop_path'];
  406. $b15 = $data['images']["backdrops"];
  407. $i = '0';
  408. foreach ($b15 as $valor2) {
  409. if ($i < 10) {
  410. $imgs .= 'https://image.tmdb.org/t/p/w300' . $valor2['file_path'] . "\n";
  411. $i += 1;
  412. }
  413. }
  414.  
  415. $b16 = $data['genres'];
  416. $generos = array();
  417. foreach ($b16 as $ci) {
  418. $generos[] = $ci['name'];
  419. }
  420.  
  421. // ##########################################
  422. $api_2 = wp_remote_get(tmdburl . "movie/" . $idmovie . "/credits?append_to_response=images,trailers&language=" . $lang . "&include_image_language=" . $lang . ",null&api_key=" . $key . "");
  423. $json_2 = wp_remote_retrieve_body($api_2);
  424. $data2 = json_decode($json_2, true);
  425. // ##########################################
  426. $c1 = $data2['cast'];
  427. $i = '0';
  428. foreach ($c1 as $valor) {
  429. if ($i < 10) {
  430. $actores .= $valor['name'] . ",";
  431. $i += 1;
  432. }
  433. }
  434.  
  435. $i = '0';
  436. foreach ($c1 as $valor) {
  437. if ($i < 10) {
  438. if ($valor['profile_path'] == null) {
  439. $valor['profile_path'] = "null";
  440. }
  441. $d_actores .= "[" . $valor['profile_path'] . ";" . $valor['name'] . "," . $valor['character'] . "]";
  442. $i += 1;
  443. }
  444. }
  445.  
  446. $c2 = $data2['crew'];
  447. foreach ($c2 as $valorc) {
  448. $departamente = $valorc['department'];
  449. if ($valorc['profile_path'] == null) {
  450. $valorc['profile_path'] = "null";
  451. }
  452. if ($departamente == "Directing") {
  453. $d_dir .= "[" . $valorc['profile_path'] . ";" . $valorc['name'] . "]";
  454. }
  455. if ($departamente == "Directing") {
  456. $dir .= $valorc['name'] . ",";
  457. }
  458. }
  459. // ##########################################
  460. $api_3 = wp_remote_get(tmdburl . "movie/" . $idmovie . "/videos?append_to_response=images,trailers&language=" . $lang . "&include_image_language=" . $lang . ",null&api_key=" . $key);
  461. $json_3 = wp_remote_retrieve_body($api_3);
  462. $data3 = json_decode($json_3, true);
  463. // ##########################################
  464. $d1 = $data3['results'];
  465. foreach ($d1 as $yt) {
  466. $youtube .= "[" . $yt['key'] . "]";
  467. break;
  468. }
  469.  
  470. // added by Lava
  471. $hours = ltrim(gmdate("i", $b1), 0);
  472. $minutes = ltrim(gmdate("s", $b1), 0);
  473.  
  474. $hours = empty($hours) ? 0 : $hours;
  475. $minutes = empty($minutes) ? 0 : $minutes;
  476.  
  477. $b1 = $hours . 'h ' . $minutes . 'm';
  478.  
  479. $youtube_iframe = '<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/' . substr($youtube, 1, -1) . '\" frameborder=\"0\" allowfullscreen></iframe>';
  480.  
  481. // ##########################################
  482.  
  483. $my_post = array(
  484. 'post_title' => dt_clear($b3),
  485. 'post_content' => dt_clear($b4),
  486. 'post_date' => $b111,
  487. 'post_date_gmt' => $b111,
  488. 'post_status' => 'publish',
  489. 'post_type' => 'post',
  490. 'post_author' => 1,
  491. );
  492.  
  493. // vericador
  494. global $wpdb;
  495. $consulta = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'Checkbx2' AND meta_value = '{$imdb}' ";
  496. $verificar = $wpdb->get_results($consulta, OBJECT);
  497. if ($verificar) {
  498. echo '<strong>ERROR:</strong> ' . __d('content already exists');
  499. } else {
  500. $post_id = wp_insert_post($my_post);
  501. echo '<span class="import_completed">' . __d('imported') . '</span> <a href="' . esc_url(home_url()) . '?p=' . $post_id . '" target="_blank"><strong>' . $b3 . '</strong></a> (' . $a3 . ')';
  502. }
  503.  
  504. wp_set_post_terms($post_id, $dir, 'directors', false);
  505. wp_set_post_terms($post_id, $a3, 'release-year', false);
  506. wp_set_post_terms($post_id, $actores, 'cast', false);
  507. wp_set_object_terms($post_id, $generos, 'category', false);
  508. wp_set_object_terms($post_id, $a7, 'countries', true);
  509. wp_set_object_terms($post_id, $a4, 'imdbRating', false);
  510. wp_set_object_terms($post_id, "HD", 'quality', false);
  511. wp_set_post_tags($post_id, $b12 . ' Online,123movies,Gomovies,YesMovies,Putlocker,bmovies, ' . $b12, true);
  512. wp_set_post_tags($post_id, 'Free movies ' . $a3, true);
  513. wp_set_post_tags($post_id, $b12 . ' 123movies ', true);
  514. wp_set_post_tags($post_id, $b12 . ' Gomovies ', true);
  515. wp_set_post_tags($post_id, $b12 . ' Putloker ', true);
  516. wp_set_post_tags($post_id, $b12 . ' bmovies ', true);
  517. wp_set_post_tags($post_id, $actores . '', true);
  518. add_post_meta($post_id, "Checkbx2", ($imdb), true);
  519. add_post_meta($post_id, "idtmdb", ($idtmdb), true);
  520. add_post_meta($post_id, "poster_url", ($upimg), true);
  521. add_post_meta($post_id, "fondo_player", ($b14), true);
  522. add_post_meta($post_id, "dt_backdrop", ($b14), true);
  523. add_post_meta($post_id, "imagenes", ($imgs), true);
  524. add_post_meta($post_id, "youtube_id", ($youtube), true);
  525. add_post_meta($post_id, "imdbRating", ($a4), true);
  526. add_post_meta($post_id, "imdbVotes", ($a5), true);
  527. add_post_meta($post_id, "Rated", ($a6), true);
  528. add_post_meta($post_id, "countries", ($a7), true);
  529. add_post_meta($post_id, "Title", ($b12), true);
  530. add_post_meta($post_id, "field_date", ($b11), true);
  531. add_post_meta($post_id, "vote_average", ($b10), true);
  532. add_post_meta($post_id, "vote_count", ($b9), true);
  533. add_post_meta($post_id, "tagline", ($b2), true);
  534. //add_post_meta($post_id, "runtime", ($b1) , true); previous
  535. add_post_meta($post_id, "field_runtime", ($b1), true); // added by Lava
  536. add_post_meta($post_id, "field_trailer", ($youtube_iframe), true);
  537.  
  538. dt_upload_image($upimg, $post_id);
  539. }
  540. }
  541. }
  542. die();
  543. }
  544.  
  545. /* Post TV Shows
  546. -------------------------------------------------------------------------------
  547. */
  548. function dbm_post_tv()
  549. {
  550. if (isset($_POST['send-series-nonce']) and wp_verify_nonce($_POST['send-series-nonce'], 'send-series')) {
  551. if (current_user_can('manage_options')) {
  552. $key = tmdbkey;
  553. $lang = tmdblang;
  554. $slug = "/" . get_option('dt_tvshows_slug', 'tvshows');
  555. $ids = $_POST["idtv"];
  556. if (($ids != null)) {
  557. $urla = wp_remote_get(tmdburl . "tv/" . $ids . "?append_to_response=images,trailers&language=" . $lang . "&include_image_language=" . $lang . ",null&api_key=" . $key);
  558. $json2 = wp_remote_retrieve_body($urla);
  559. $data2 = json_decode($json2, true);
  560. // ##########################################
  561. $name = $data2['name'];
  562. $tvid = $data2['id'];
  563. $episodes = $data2['number_of_episodes'];
  564. $seasons = $data2['number_of_seasons'];
  565. $year = substr($data2['first_air_date'], 0, 4);
  566. $date1 = $data2['first_air_date'];
  567. $date2 = $data2['last_air_date'];
  568. $overview = $data2['overview'];
  569. $popularidad = $data2['popularity'];
  570. $originalname = $data2['original_name'];
  571. $promedio = $data2['vote_average'];
  572. $votos = $data2['vote_count'];
  573. $tipo = $data2['type'];
  574. $web = $data2['homepage'];
  575. $status = $data2['status'];
  576. $poster = $data2['poster_path'];
  577. if ($get_img = $data2['poster_path']) {
  578. $upload_poster = 'https://image.tmdb.org/t/p/w200' . $get_img;
  579. }
  580. $backdrop = 'https://image.tmdb.org/t/p/w1280' . $data2['backdrop_path'];
  581. // Forech!
  582. $i = '0';
  583. $images = $data2['images']["backdrop"];
  584. foreach ($images as $valor2) {
  585. if ($i < 10) {
  586. $imgs .= 'https://image.tmdb.org/t/p/w300' . $valor2['file_path'] . "\n";
  587. $i += 1;
  588. }
  589. }
  590.  
  591. $genres = $data2['genres'];
  592. $generos = array();
  593. foreach ($genres as $ci) {
  594. $generos[] = $ci['name'];
  595. }
  596. $networks = $data2['networks'];
  597. foreach ($networks as $co) {
  598. $redes .= $co['name'];
  599. }
  600. $studio = $data2['production_companies'];
  601. foreach ($studio as $ht) {
  602. $estudios .= $ht['name'] . ",";
  603. }
  604. $creator = $data2['created_by'];
  605. foreach ($creator as $cg) {
  606. $creador .= $cg['name'] . ",";
  607. }
  608. foreach ($creator as $ag) {
  609. if ($ag['profile_path'] == null) {
  610. $ag['profile_path'] = "null";
  611. }
  612. $creador_d .= "[" . $ag['profile_path'] . ";" . $ag['name'] . "]";
  613. }
  614. $duration = $data2['episode_run_time'];
  615. foreach ($duration as $tm) {
  616. $duracion .= $tm;
  617. break;
  618. }
  619. // ##########################################
  620. $urlb = wp_remote_get(tmdburl . "tv/" . $ids . "/credits?append_to_response=images,trailers&language=" . $lang . "&include_image_language=" . $lang . ",null&api_key=" . $key);
  621. $json3 = wp_remote_retrieve_body($urlb);
  622. $data3 = json_decode($json3, true);
  623. // ##########################################
  624. $cast = $data3['cast'];
  625. $i = '0';
  626. foreach ($cast as $valor) {
  627. if ($i < 10) {
  628. $actores .= $valor['name'] . ",";
  629. $i += 1;
  630. }
  631. }
  632.  
  633. $i = '0';
  634. foreach ($cast as $valor) {
  635. if ($i < 10) {
  636. if ($valor['profile_path'] == null) {
  637. $valor['profile_path'] = "null";
  638. }
  639. $d_actores .= "[" . $valor['profile_path'] . ";" . $valor['name'] . "," . $valor['character'] . "]";
  640. $i += 1;
  641. }
  642. }
  643.  
  644. // ##########################################
  645. $urlc = wp_remote_get(tmdburl . "tv/" . $ids . "/videos?append_to_response=images,trailers&language=" . $lang . "&include_image_language=" . $lang . ",null&api_key=" . $key);
  646. $json4 = wp_remote_retrieve_body($urlc);
  647. $data4 = json_decode($json4, true);
  648. // ##########################################
  649. $video = $data4['results'];
  650. foreach ($video as $yt) {
  651. $youtube .= "[" . $yt['key'] . "]";
  652. break;
  653. }
  654. // ##########################################
  655. $my_post = array(
  656. 'post_title' => dt_clear($name),
  657. 'post_content' => dt_clear($overview),
  658. 'post_status' => 'publish',
  659. 'post_type' => 'tvshows',
  660. 'post_date' => $date1,
  661. 'post_date_gmt' => $date1,
  662. 'post_author' => 1,
  663. );
  664.  
  665. // vericador
  666. global $wpdb;
  667. $consulta = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'ids' AND meta_value = '{$tvid}' ";
  668. $verificar = $wpdb->get_results($consulta, OBJECT);
  669. if ($verificar) {
  670. echo '<strong>ERROR:</strong> ' . __d('content already exists');
  671. } else {
  672. $post_id = wp_insert_post($my_post);
  673. echo '<span class="import_completed">' . __d('imported') . '</span> <a href="' . esc_url(home_url()) . '?p=' . $post_id . '" target="_blank"><strong>' . $name . '</strong></a> (' . $year . ')';
  674. }
  675. wp_set_post_terms($post_id, $year, 'release-year', false);
  676. wp_set_object_terms($post_id, $generos, 'category', false);
  677. wp_set_post_terms($post_id, $redes, 'networks', false);
  678. wp_set_post_terms($post_id, $estudios, 'studio', false);
  679. wp_set_post_terms($post_id, $actores, 'cast', false);
  680. wp_set_post_terms($post_id, $creador, 'directors', false);
  681. add_post_meta($post_id, "ids", ($tvid), true);
  682. add_post_meta($post_id, "poster_url", ($upload_poster), true);
  683. add_post_meta($post_id, "fondo_player", ($backdrop), true);
  684. add_post_meta($post_id, "dt_backdrop", ($backdrops), true);
  685. add_post_meta($post_id, "imagenes", ($imgs), true);
  686. add_post_meta($post_id, "youtube_id", ($youtube), true);
  687. add_post_meta($post_id, "first_air_date", ($date1), true);
  688. add_post_meta($post_id, "last_air_date", ($date2), true);
  689. add_post_meta($post_id, "number_of_episodes", ($episodes), true);
  690. add_post_meta($post_id, "number_of_seasons", ($seasons), true);
  691. add_post_meta($post_id, "original_name", ($originalname), true);
  692. add_post_meta($post_id, "status", ($status), true);
  693. add_post_meta($post_id, "serie_vote_average", ($promedio), true);
  694. add_post_meta($post_id, "serie_vote_count", ($votos), true);
  695. add_post_meta($post_id, "episode_run_time", ($duracion), true);
  696. dt_upload_image($upload_poster, $post_id);
  697. }
  698. }
  699. }
  700. die();
  701. }
  702.  
  703. /* All actions
  704. -------------------------------------------------------------------------------
  705. */
  706. add_action('admin_menu', 'dbmovies_page');
  707. add_action('admin_enqueue_scripts', 'dbmovies_assets');
  708.  
  709. /* Ajax actions
  710. -------------------------------------------------------------------------------
  711. */
  712. add_action('wp_ajax_dbm_status', 'dbm_status');
  713. add_action('wp_ajax_dbm_get_movies', 'dbm_get_movies');
  714. add_action('wp_ajax_dbm_get_tv', 'dbm_get_tv');
  715. add_action('wp_ajax_dbm_post_movie', 'dbm_post_movie');
  716. add_action('wp_ajax_dbm_post_tv', 'dbm_post_tv');
  717.  
  718. add_action('wp_ajax_nopriv_dbm_status', 'dbm_status');
  719. add_action('wp_ajax_nopriv_dbm_get_movies', 'dbm_get_movies');
  720. add_action('wp_ajax_nopriv_dbm_get_tv', 'dbm_get_tv');
  721. add_action('wp_ajax_nopriv_dbm_post_movie', 'dbm_post_movie');
  722. add_action('wp_ajax_nopriv_dbm_post_tv', 'dbm_post_tv');
  723. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement