Exemplo n.º 1
0
 public static function getKinopoiskLinkByName($name)
 {
     $result = \Hawkart\Megatv\PeopleTable::getList(array('filter' => array("=UF_TITLE" => $name), 'select' => array("UF_KINOPOISK_LINK")));
     if ($row = $result->fetch()) {
         return $row["UF_KINOPOISK_LINK"];
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Import People from xml EPG
  *
  * @return array
  */
 public static function importPeople($arRoles = false)
 {
     $file = "http://xmldata.epgservice.ru/EPGService/hs/xmldata/saturn/people_list";
     $xml = simplexml_load_file($file);
     $arList = array();
     $result = PeopleTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "ID", "UF_TITLE")));
     while ($row = $result->fetch()) {
         $arList[$row["UF_EPG_ID"]] = $row;
     }
     if (!$arRoles) {
         $arRoles = self::importRole();
     }
     foreach ($xml->element as $arElement) {
         $el_attr = $arElement->attributes();
         $epg_id = (string) $el_attr["id"];
         $title = (string) $arElement->name;
         $role_attr = $arElement->role->attributes();
         $role_epg_id = (string) $role_attr["id"];
         $role_id = $arRoles[$role_epg_id]["ID"];
         if (!is_array($arList[$epg_id])) {
             $arFields = array("UF_EPG_ID" => $epg_id, "UF_TITLE" => $title, "UF_ROLE_ID" => $role_id);
             $result = PeopleTable::add($arFields);
             if ($result->isSuccess()) {
                 $id = $result->getId();
                 $arFields["ID"] = $id;
                 $arList[$epg_id] = $arFields;
             } else {
                 $errors = $result->getErrorMessages();
                 //\CDev::pre($arFields);\CDev::pre($errors);
             }
         }
     }
     unset($arRoles);
     return $arList;
 }
Exemplo n.º 3
0
<?php

/**
 * Parse kinopoisk to get links to actors
 */
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__) . '/../');
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
set_time_limit(0);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
global $USER, $APPLICATION;
if (!is_object($USER)) {
    $USER = new CUser();
}
$arPeoples = array();
$result = \Hawkart\Megatv\PeopleTable::getList(array('filter' => array("UF_KINOPOISK_LINK" => false), 'select' => array("UF_TITLE", "ID", "UF_KINOPOISK_LINK")));
while ($row = $result->fetch()) {
    $arPeoples[$row["ID"]] = $row;
    /*\Hawkart\Megatv\PeopleTable::update($row["ID"], array(
          "UF_KINOPOISK_LINK" => str_replace("//name", "/name", $row["UF_KINOPOISK_LINK"])
      ));*/
}
//die();
$login = \COption::GetOptionString("grain.customsettings", "KINOPOISK_LOGIN");
$password = \COption::GetOptionString("grain.customsettings", "KINOPOISK_PASS");
$kinopoisk = new \Hawkart\Megatv\Kinopoisk($login, $password);
foreach ($arPeoples as $arActor) {
    $actor = urlencode($arActor["UF_TITLE"]);
    if ($link = $kinopoisk->searchActor($actor)) {
        \Hawkart\Megatv\PeopleTable::update($arActor["ID"], array("UF_KINOPOISK_LINK" => $link));
        sleep(2);