Пример #1
0
 /**
  * Handle import
  *
  * @param \SimplePie_Item $item
  * @param \Protalk\MediaBundle\Entity\Feed $feed
  * @return bool
  */
 public function handleImport(SimplePie_Item $item, Feed $feed)
 {
     $data = $item->get_item_tags('http://search.yahoo.com/mrss/', 'group');
     $enclosures = $item->get_enclosures();
     $schemaArray = $data[0]['child']['http://search.yahoo.com/mrss/'];
     $videoURL = $schemaArray['content'][0]['attribs']['']['url'];
     if (!$videoURL) {
         return false;
     }
     $itemUploaded = new \DateTime($item->get_date());
     $itemIsSuitable = $this->checkSuitableForImport($item, $itemUploaded, $feed->getLastImportedDate());
     if (!$itemIsSuitable) {
         return false;
     }
     // TODO: modify this when media provider PR is merged
     $contentTemplate = "<iframe width=\"500\" height=\"315\" src=\"" . $videoURL . "\" frameborder=\"0\" allowfullscreen></iframe>";
     $duration = gmdate("H:i:s", $enclosures[0]->get_duration());
     $importItem = new ImportItem();
     $importItem->title = $item->get_title();
     $importItem->date = new \DateTime($item->get_date());
     $importItem->description = $enclosures[0]->get_description();
     $importItem->length = $duration;
     $importItem->mediatype = $feed->getMediatype();
     $importItem->content = $contentTemplate;
     $importItem->hostName = $feed->getName();
     $importItem->hostUrl = $item->get_permalink();
     $importItem->thumbnail = $enclosures[0]->get_thumbnail(0);
     $this->insertMedia($importItem, new Media());
     // TODO: add default language to feed entity <-- do this when multi-language support is added?
     return true;
 }
Пример #2
0
 /**
  * Handle import
  *
  * @param \SimplePie_Item $item
  * @param \Protalk\MediaBundle\Entity\Feed $feed
  * @return bool
  */
 public function handleImport(SimplePie_Item $item, Feed $feed)
 {
     $enclosures = $item->get_enclosures();
     $videoId = $item->get_item_tags('http://blip.tv/dtd/blip/1.0', 'embedLookup');
     $videoId = $videoId[0]['data'];
     if (!$videoId) {
         return false;
     }
     // TODO: modify this when media provider PR is merged
     $contentTemplate = "<iframe src=\"http://blip.tv/play/" . $videoId . ".html?p=1\" width=\"532\" height=\"334\" frameborder=\"0\" allowfullscreen></iframe><embed type=\"application/x-shockwave-flash\" src=\"http://a.blip.tv/api.swf#" . $videoId . "\" style=\"display:none\"></embed>";
     $itemUploaded = $item->get_item_tags('http://blip.tv/dtd/blip/1.0', 'datestamp');
     $itemUploaded = new \DateTime($itemUploaded[0]['data']);
     $itemIsSuitable = $this->checkSuitableForImport($item, $itemUploaded, $feed->getLastImportedDate());
     if (!$itemIsSuitable) {
         return false;
     }
     $duration = $item->get_item_tags('http://blip.tv/dtd/blip/1.0', 'runtime');
     $duration = gmdate("H:i:s", $duration[0]['data']);
     $description = $item->get_item_tags('http://blip.tv/dtd/blip/1.0', 'puredescription');
     $description = $description[0]['data'];
     $importItem = new ImportItem();
     $importItem->title = $item->get_title();
     $importItem->date = new \DateTime($item->get_date());
     $importItem->description = $description;
     $importItem->length = $duration;
     $importItem->mediatype = $feed->getMediatype();
     $importItem->content = $contentTemplate;
     $importItem->hostName = $feed->getName();
     $importItem->hostUrl = $item->get_permalink();
     $importItem->thumbnail = $enclosures[0]->get_thumbnail(0);
     $this->insertMedia($importItem, new Media());
     // TODO: add default language to feed entity <-- do this when multi-language support is added?
     return true;
 }
Пример #3
0
 /**
  * Handle import
  *
  * @param \SimplePie_Item $item
  * @param \Protalk\MediaBundle\Entity\Feed $feed
  * @return bool
  */
 public function handleImport(SimplePie_Item $item, Feed $feed)
 {
     $enclosures = $item->get_enclosures();
     $itemUploaded = new \DateTime($item->get_date());
     $content = $enclosures[0]->get_link();
     if (!$content) {
         return false;
     }
     $itemIsSuitable = $this->checkSuitableForImport($item, $itemUploaded, $feed->getLastImportedDate());
     if (!$itemIsSuitable) {
         return false;
     }
     $importItem = new ImportItem();
     $importItem->title = $item->get_title();
     $importItem->date = new \DateTime($item->get_date());
     $importItem->description = $item->get_description();
     $importItem->length = 'tbc';
     //item duration must be manually added!
     $importItem->mediatype = $feed->getMediatype();
     $importItem->content = $content;
     $importItem->hostName = $feed->getName();
     $importItem->hostUrl = $item->get_permalink();
     $this->insertMedia($importItem, new Media());
     // TODO: add default language to feed entity <-- do this when multi-language support is added?
     return true;
 }
Пример #4
0
 /**
  * Set the date of current import in Feed entity
  *
  * @param \Protalk\MediaBundle\Entity\Feed $feed
  */
 private function setFeedImportDate(Feed $feed)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $feed->setLastImportedDate(new \DateTime('now'));
     $em->persist($feed);
     $em->flush();
 }