PageRenderTime 50ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/priority_video_all.php

https://gitlab.com/mtellezgalindo/script-deportes-app
PHP | 322 lines | 300 code | 15 blank | 7 comment | 65 complexity | 6991533272b3963ac9508093be0bfb85 MD5 | raw file
  1. <?php
  2. date_default_timezone_set('America/Mexico_City');
  3. //error_reporting(E_ALL ^ E_NOTICE);
  4. if(isset($_REQUEST['section']) && $_REQUEST['section'] != ""){
  5. $seccion = $_REQUEST['section'];
  6. }else{
  7. $seccion = "home";
  8. }
  9. if(isset($_REQUEST['formatvid']) && $_REQUEST['formatvid'] != ""){
  10. $formatvid = $_REQUEST['formatvid'];
  11. }else{
  12. $formatvid = "apps";
  13. }
  14. switch ($seccion) {
  15. case 'home':
  16. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes.mix.js';
  17. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes.mvideo.js';
  18. break;
  19. case 'futbol':
  20. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/futbol.mix.js';
  21. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/futbol.video.js';
  22. break;
  23. case 'seleccion':
  24. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/seleccion-mexicana.mix.js';
  25. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/seleccion-mexicana.video.js';
  26. break;
  27. case 'fut_mexicano':
  28. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/futbol-mexicano.mix.js';
  29. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/futbol-mexicano.video.js';
  30. break;
  31. case 'fut_internacional':
  32. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/futbol-internacional.mix.js';
  33. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/futbol-internacional.video.js';
  34. break;
  35. case 'boxeo':
  36. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/boxeo.mix.js';
  37. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/boxeo.video.js';
  38. break;
  39. case 'nba':
  40. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/nba-basquetbol.mix.js';
  41. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/nba-basquetbol.video.js';
  42. break;
  43. case 'beisbol':
  44. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/beisbol.mix.js';
  45. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/beisbol.video.js';
  46. break;
  47. case 'nfl':
  48. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/nfl-futbol-americano.mix.js';
  49. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/nfl-futbol-americano.video.js';
  50. break;
  51. case 'mas_deporte':
  52. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/mas-deportes.mix.js';
  53. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/mas-deportes.video.js';
  54. break;
  55. case 'tdn':
  56. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/tdn.mix.js';
  57. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/tdn.video.js';
  58. break;
  59. case 'autos':
  60. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/autos.mix.js';
  61. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/autos.video.js';
  62. break;
  63. case 'golf':
  64. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/golf.mix.js';
  65. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/golf.video.js';
  66. break;
  67. case 'tenis':
  68. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/tenis.mix.js';
  69. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/tenis.video.js';
  70. break;
  71. case 'tdw':
  72. $req_mix = 'http://deportes.televisa.com/content/televisa/deportes/tdw.mix.js';
  73. $req_carousel = 'http://deportes.televisa.com/content/televisa/deportes/tdw.video.js';
  74. break;
  75. }
  76. $dom_feed= explode("content/televisa", $req_mix);
  77. $dominio= trim($dom_feed[0], "/");
  78. $subdominio= array("m4v.","media.","flash.");
  79. $cURL = curl_init($req_mix);
  80. curl_setopt($cURL,CURLOPT_RETURNTRANSFER, TRUE);
  81. $app_deo = curl_exec($cURL);
  82. //$app_deo = utf8_encode(curl_exec($cURL));
  83. $deportes_app = json_decode($app_deo, true); //echo "<pre>"; print_r($deportes_app); echo "</pre>";die();
  84. $cURL_car = curl_init($req_carousel);
  85. curl_setopt($cURL_car,CURLOPT_RETURNTRANSFER, TRUE);
  86. $app_car = curl_exec($cURL_car);
  87. //$app_car = utf8_encode(curl_exec($cURL_car));
  88. $deportes_app_car = json_decode($app_car, true); //echo "<pre>"; print_r($deportes_app_car); echo "</pre>";die();
  89. $array_feed= array();
  90. $i= 0;
  91. //RECORRIENDO MIX
  92. if($deportes_app['items'] != null || $deportes_app['items'] != ""){
  93. foreach($deportes_app['items'] as $key => $val){
  94. if($val["typeElement"] == "video"){
  95. if(isset($val['urls'][$formatvid]) && $val['urls'][$formatvid] != ""){
  96. $url_video= $val['urls'][$formatvid];
  97. //$url_video= $val['urls']["apps"];
  98. $ur_vid_aux= explode("?", $url_video);
  99. if(count($ur_vid_aux > 1)){
  100. $url_video= $ur_vid_aux[0];
  101. }
  102. $url_video= strtolower($url_video);
  103. $url_video= str_replace($subdominio, 'apps.',$url_video);
  104. if(isset($val['description']) && $val['description'] != ""){
  105. $description= $val['description'];
  106. }else{
  107. $description= $val['title'];
  108. }
  109. if(isset($val['publidate']) && $val['publidate'] != ""){
  110. $date_pub= date('D, d M Y H:i:s ',strtotime($val['publidate']));
  111. $pubdate_unixt= strtotime($val['publidate']);
  112. }else{
  113. $date_pub= date("D, d M Y H:i:s");
  114. $pubdate_unixt= time();
  115. }
  116. if(isset($val['duration']) && $val['duration'] != ""){
  117. $duration= $val['duration'];
  118. }else{
  119. $duration= "10";
  120. }
  121. if(isset($val['still']) && $val['still'] != ""){
  122. $still= $val['still'];
  123. }else{
  124. $still= $val['thumb'];
  125. }
  126. $val_still= strpos($still, 'http://');
  127. if($val_still === false){
  128. $still= $dominio.$still;
  129. }
  130. $sepurl_still= explode("?", $still);
  131. if(count($sepurl_still) > 1){
  132. $still= $sepurl_still[0];
  133. $still= str_replace($subdominio, 'apps.',$still);
  134. }
  135. $thumb= $val['thumb'];
  136. $val_thumb= strpos($thumb, 'http://');
  137. if($val_thumb === false){
  138. $thumb= $dominio.$thumb;
  139. }
  140. $sepurl_thumb= explode("?", $thumb);
  141. if(count($sepurl_thumb) > 1){
  142. $thumb= $sepurl_thumb[0];
  143. $thumb= str_replace($subdominio, 'apps.',$thumb);
  144. }
  145. $array_feed[$i]['unixtime']= $pubdate_unixt;
  146. $array_feed[$i]['section']= "mix";
  147. $array_feed[$i]['ind_feed']= $key;
  148. $array_feed[$i]['title']= $val['title'];
  149. $array_feed[$i]['link']= $val['urlpublic'];
  150. $array_feed[$i]['description']= $description;
  151. $array_feed[$i]['pubDate']= $date_pub;
  152. $array_feed[$i]['pubDateTime']= $date_pub;
  153. $array_feed[$i]['url_video']= $url_video;
  154. $array_feed[$i]['duration']= $duration;
  155. $array_feed[$i]['program']= 'deportes';
  156. $array_feed[$i]['role']= 'deportes';
  157. $array_feed[$i]['path']= $val['path'];
  158. $array_feed[$i]['keywords']= $val['keywords'];
  159. $array_feed[$i]['thumbnail']= $thumb;
  160. $array_feed[$i]['still']= $still;
  161. $array_feed[$i]['programid']= "0129";
  162. $array_feed[$i]['guid']= $val['guid'];
  163. $i++;
  164. }
  165. }
  166. }
  167. }
  168. //RECORRIENDO COMPONENTE MULTIMEDIA
  169. $show_items_cm= 0;
  170. if($deportes_app_car['items'] != null || $deportes_app['items'] != ""){
  171. foreach($deportes_app_car['items'] as $key => $val){
  172. if(isset($val['urls'][$formatvid]) && $val['urls'][$formatvid] != ""){
  173. $url_video= $val['urls'][$formatvid];
  174. $ur_vid_aux= explode("?", $url_video);
  175. if(count($ur_vid_aux > 1)){
  176. $url_video= $ur_vid_aux[0];
  177. }
  178. $url_video= strtolower($url_video);
  179. $url_video= str_replace($subdominio, 'apps.',$url_video);
  180. if(isset($val['description']) && $val['description'] != ""){
  181. $description= $val['description'];
  182. }else{
  183. $description= $val['title'];
  184. }
  185. if(isset($val['publidate']) && $val['publidate'] != ""){
  186. $date_pub= date('D, d M Y H:i:s ',strtotime($val['publidate']));
  187. $pubdate_unixt= strtotime($val['publidate']);
  188. }else{
  189. $date_pub= date("D, d M Y H:i:s");
  190. $pubdate_unixt= time();
  191. }
  192. if(isset($val['duration']) && $val['duration'] != ""){
  193. $duration= $val['duration'];
  194. }else{
  195. $duration= "10";
  196. }
  197. if(isset($val['still']) && $val['still'] != ""){
  198. $still= $val['still'];
  199. }else{
  200. $still= $val['thumb'];
  201. }
  202. $val_still= strpos($still, 'http://');
  203. if($val_still === false){
  204. $still= $dominio.$still;
  205. }
  206. $sepurl_still= explode("?", $still);
  207. if(count($sepurl_still) > 1){
  208. $still= $sepurl_still[0];
  209. $still= str_replace($subdominio, 'apps.',$still);
  210. }
  211. $thumb= $val['thumb'];
  212. $val_thumb= strpos($thumb, 'http://');
  213. if($val_thumb === false){
  214. $thumb= $dominio.$thumb;
  215. }
  216. $sepurl_thumb= explode("?", $thumb);
  217. if(count($sepurl_thumb) > 1){
  218. $thumb= $sepurl_thumb[0];
  219. $thumb= str_replace($subdominio, 'apps.',$thumb);
  220. }
  221. $array_feed[$i]['unixtime']= $pubdate_unixt;
  222. $array_feed[$i]['section']= "carousel";
  223. $array_feed[$i]['ind_feed']= $key;
  224. $array_feed[$i]['title']= $val['title'];
  225. $array_feed[$i]['link']= $val['urlpublic'];
  226. $array_feed[$i]['description']= $description;
  227. $array_feed[$i]['pubDate']= $date_pub;
  228. $array_feed[$i]['pubDateTime']= $date_pub;
  229. $array_feed[$i]['url_video']= $url_video;
  230. $array_feed[$i]['duration']= $duration;
  231. $array_feed[$i]['program']= 'deportes';
  232. $array_feed[$i]['role']= 'deportes';
  233. $array_feed[$i]['path']= $val['path'];
  234. $array_feed[$i]['keywords']= $val['keywords'];
  235. $array_feed[$i]['thumbnail']= $thumb;
  236. $array_feed[$i]['still']= $still;
  237. $array_feed[$i]['programid']= "0129";
  238. $array_feed[$i]['guid']= $val['guid'];
  239. $i++;
  240. $show_items_cm++; //contador dee elemntos en ComponenteMultimedia
  241. }
  242. }
  243. }
  244. //echo "<pre>"; print_r($array_feed); echo "</pre>"; //rsort($array_feed);Ordenando elementos por timestamp
  245. if($seccion == "home"){ //Eliminando ultimos 3 items ::: asociados al componente multimedia
  246. $array_feed_size= count($array_feed);
  247. unset($array_feed[$array_feed_size-3]);
  248. unset($array_feed[$array_feed_size-2]);
  249. unset($array_feed[$array_feed_size-1]); //echo "<pre>"; print_r($array_feed); echo "</pre>"; //die();
  250. }
  251. header("Content-type: text/xml; charset=ISO-8859-1");
  252. echo '<'.'?xml version="1.0" encoding="ISO-8859-1"?'.'> <rss version="2.0"
  253. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  254. xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  255. xmlns:dc="http://purl.org/dc/elements/1.1/"
  256. xmlns:media="http://search.yahoo.com/mrss/"
  257. xmlns:atom="http://www.w3.org/2005/Atom">';
  258. echo "\n";
  259. ?>
  260. <channel>
  261. <title>televisa.com</title>
  262. <link>http://www.televisa.com</link>
  263. <description><?=utf8_decode("El sitio número de internet de habla hispana con el mejor contenido de noticias, espectáculos, telenovelas, deportes, futbol, estadísticas y mucho más.")?></description>
  264. <image>
  265. <title>televisa.com</title>
  266. <url>http://i.esmas.com/img/univ/portal/rss/feed_1.jpg</url>
  267. <link>http://www.televisa.com</link>
  268. </image>
  269. <language>es-mx</language>
  270. <copyright>2005 Comercio Mas S.A. de C.V</copyright>
  271. <managingEditor>ulises.blanco@esmas.net (Ulises Blanco)</managingEditor>
  272. <webMaster>feeds@esmas.com (feeds Esmas.com)</webMaster>
  273. <pubDate><?php echo date("D, d M Y H:i:s")?> GMT</pubDate>
  274. <lastBuildDate><?php echo date("D, d M Y H:i:s")?> GMT</lastBuildDate>
  275. <category>Home Principal esmas</category>
  276. <generator>GALAXY 1.0</generator>
  277. <atom:link href="http://feeds.esmas.com/data-feeds-esmas/xml/index.xml" rel="self" type="application/rss+xml" />
  278. <ttl>60</ttl>
  279. <?php if($array_feed != "" || $array_feed != null){
  280. foreach($array_feed as $key_item => $value_element){
  281. if($value_element['url_video'] != ""){ ?>
  282. <item>
  283. <title><![CDATA[<?=utf8_decode($value_element['title']);?>]]></title>
  284. <link><?=$value_element['link'];?></link>
  285. <description><![CDATA[<?=utf8_decode($value_element['description'])?>]]></description>
  286. <pubDate><?=trim($value_element['pubDate']);?> CDT</pubDate>
  287. <pubDateTime><?=trim($value_element['pubDateTime'])?> CDT</pubDateTime>
  288. <media:content url='<?=$value_element['url_video']?>' fileSize='' type='video' medium='video' expression='full' duration='<?php echo $value_element['duration']?>' />
  289. <media:title type='plain'><![CDATA[<?=utf8_decode($value_element['title']);?>]]></media:title>
  290. <media:credit role='author' scheme='<?=$value_element['role'];?>'><![CDATA[<?php echo $value_element['path'];?>]]></media:credit>
  291. <media:description type='plain'><![CDATA[<?=utf8_decode($value_element['description']);?>]]></media:description>
  292. <media:group>
  293. <media:content url='<?=$value_element['still'];?>' medium='image' height='360' width='640' />
  294. </media:group>
  295. <media:keywords><![CDATA[<?=utf8_decode($value_element['keywords']);?>]]></media:keywords>
  296. <media:thumbnail url='<?=$value_element['thumbnail']?>'/>
  297. <media:text>http://comentarios.esmas.com/feeds/comentarios.php?url=<?=$value_element['link']?></media:text>
  298. <guid isPermaLink='false'><?=$value_element['guid']?></guid>
  299. <category><![CDATA[<?= $value_element['path'];?>]]></category>
  300. <categoryid><?=$value_element['programid']?></categoryid>
  301. <comments>http://comentarios.esmas.com/feeds/comentarios.php?url=<?php echo $value_element['link']?></comments>
  302. </item>
  303. <?php }
  304. }
  305. } ?>
  306. </channel>
  307. </rss>