<?php namespace Source\Lib;
use Dever;
class Info
{
    public function update($data)
    {
        $host = Dever::host();
        $value = Dever::db('info_value', 'source')->select(array('info_id' => $data['id']));
        if ($value) {
            foreach ($value as $k => $v) {
                if (!strstr($v['value'], $host)) {
                    $data = Dever::load('video', 'api')->remote($v['value'], false, true);
                    if (isset($data['vid'])) {
                        $update['remote'] = $data['value'];
                        $update['value'] = $data['video']['url'];
                        $update['name'] = $data['title'] ? $data['title'] : $data['desc'];
                        $update['vid'] = $data['vid'];
                        Dever::db('info_value', 'source')->update(array('id' => $v['id']), $update);
                    }
                }
            }
        }
        return $data;
    }
}