private function _canHandle(ehough_shortstop_api_HttpRequest $request, ehough_shortstop_api_HttpResponse $response) { $url = $request->getUrl(); $host = $url->getHost(); if (!tubepress_impl_util_StringUtils::endsWith($host, 'youtube.com')) { return false; } $contentType = $response->getHeaderValue('Content-Type'); $entity = $response->getEntity(); return $entity && $contentType === 'application/vnd.google.gdata.error+xml'; }
/** * Converts gdata timestamps to unix time * * @param string $rfcTime The RFC 3339 format of time * * @return int Unix time for the given RFC 3339 time */ public static function rfc3339toUnixTime($rfcTime) { $tmp = str_replace('T', ' ', $rfcTime); $tmp = preg_replace('/(\\.[0-9]{1,})?/', '', $tmp); $datetime = substr($tmp, 0, 19); if (tubepress_impl_util_StringUtils::endsWith($tmp, 'Z')) { $reset = date_default_timezone_get(); date_default_timezone_set('UTC'); $toReturn = strtotime($datetime); date_default_timezone_set($reset); return $toReturn; } $timezone = str_replace(':', '', substr($tmp, 19, 6)); return strtotime($datetime . ' ' . $timezone); }
private function _maybeGetListValueFromUrl($originalValue) { $url = null; try { $url = new ehough_curly_Url($originalValue); } catch (Exception $e) { return $originalValue; } $host = $url->getHost(); if (!tubepress_impl_util_StringUtils::endsWith($host, 'youtube.com')) { return $originalValue; } $params = $url->getQueryVariables(); if (!array_key_exists('list', $params)) { return $originalValue; } return $params['list']; }
private function _canHandle(ehough_shortstop_api_HttpRequest $request, ehough_shortstop_api_HttpResponse $response) { $url = $request->getUrl(); $host = $url->getHost(); return tubepress_impl_util_StringUtils::endsWith($host, 'vimeo.com'); }