public function testIndex()
 {
     // Given
     $fakeNumber = '+15558884441';
     $fakeRecording = 'http://help-pls.mp3';
     $fakeTranscription = 'Help me I am trapped in a phone exchange';
     $newAgent = new Agent(['extension' => 'Alderaan', 'phone_number' => '+15559997771']);
     $newAgent->save();
     $newRecording = new Recording(['caller_number' => $fakeNumber, 'transcription' => $fakeTranscription, 'recording_url' => $fakeRecording, 'agent_id' => $newAgent->id]);
     $newRecording->save();
     // When
     $response = $this->call('GET', route('agent-recordings') . '?agentNumber=15559997771');
     $responseContext = $response->getOriginalContent();
     // Then
     $this->assertCount(1, $responseContext['recordings']);
     $recordings = $responseContext['recordings'];
     $this->assertEquals($fakeNumber, $recordings[0]->caller_number);
     $this->assertEquals($fakeTranscription, $recordings[0]->transcription);
     $this->assertEquals($fakeRecording, $recordings[0]->recording_url);
     $this->assertEquals($newAgent->id, $recordings[0]->agent_id);
 }
 /**
  * Store a new recording from callback
  *
  * @return \Illuminate\Http\Response
  */
 public function storeRecording(Request $request, $agentId)
 {
     $newRecording = new Recording(['caller_number' => $request->input('Caller'), 'transcription' => $request->input('TranscriptionText'), 'recording_url' => $request->input('RecordingUrl'), 'agent_id' => $agentId]);
     $newRecording->save();
     return "Recording saved";
 }
Example #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function update($id, Request $request)
 {
     $event = Event::findOrFail($id);
     $event->title = $request->title;
     $event->intro = $request->intro;
     $event->description = $request->description;
     $event->vortex_url = $request->vortex_url;
     $event->facebook_id = $request->facebook_id;
     $event->start_date = new Carbon($request->start_date);
     $event->location = $request->location;
     if (!$request->youtube_playlist_id) {
         $event->youtube_playlist_id = null;
     } else {
         $youtubePlaylist = YoutubePlaylist::find($request->youtube_playlist_id);
         $event->youtube_playlist_id = $youtubePlaylist->id;
     }
     $event->save();
     // Organizers: TODO
     $p1 = $event->presentations[0];
     $p1->start_time = $request->p1_start_time;
     $p1->end_time = $request->p1_end_time;
     // ...
     $p1->save();
     if ($request->has('p1_person1')) {
         // TODO
     }
     if ($request->has('p1_youtube_id')) {
         $recording = Recording::where('presentation_id', '=', $p1->id)->first();
         if (!is_null($recording)) {
             if ($recording->id != $request->p1_youtube_id) {
                 $recording->presentation_id = null;
             }
         }
         $recording = Recording::where('youtube_id', '=', $request->p1_youtube_id)->first();
         if (is_null($recording)) {
             die("TODO: Video not found, redirect back with meaningful error message");
         }
         $recording->presentation_id = $p1->id;
         $recording->save();
     }
     return redirect()->action('EventsController@show', $event->id)->with('status', 'Arrangementet ble oppdatert.');
 }
 public function delete(Request $request, $rid)
 {
     //csrf protection keep from unauthorized delete
     //no need to check for server up. User will not see recording in the first place
     $user = Auth::user();
     try {
         $recording = Recording::findOrFail($rid);
         if ($recording->owner != $user->id) {
             return redirect()->back()->with('message', trans('room.show.recording.delete.unauthorized'));
         }
         $bbb = new BigBlueButton($recording->bbb_server_id);
         $bbb->deleteRecordingsWithXmlResponseArray(array('recordId' => $recording->rid));
     } catch (Exception $ex) {
         return Response::json(array('status' => $ex->getMessage()));
     }
     return redirect()->back()->with('message', trans('room.show.recording.deleted'));
 }
 public function harvestPlaylistVideos($playlistId)
 {
     $video_ids = [];
     $playlist = \App\YoutubePlaylist::where('youtube_id', '=', $playlistId)->firstOrFail();
     foreach ($this->getPlaylistVideos($playlistId) as $response) {
         $videoId = $response->snippet->resourceId->videoId;
         $recording = \App\Recording::where('youtube_id', '=', $videoId)->first();
         if (!is_null($recording)) {
             $video_ids[$recording->id] = ['playlist_position' => $response->snippet->position];
         }
     }
     $playlist->videos()->sync($video_ids);
 }
Example #6
0
 public function handle()
 {
     $channelTitle = 'Realfagsbiblioteket';
     $channelShortDescription = 'Videoer om vitenskap';
     $channelDescription = 'Vitenskap formidlet fra scenen i Realfagsbiblioteket. Realfagsbiblioteket er Norges største f*g- og forskningsbibliotek innen fagområdene fagområdene fysikk, astrofysikk, biofag, farmasi, geofag, kjemi, informatikk og matematikk.';
     $channelUrl = 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/';
     $channelAuthor = 'Realfagsbiblioteket';
     $channelAuthorEmail = '*****@*****.**';
     $channelImage = 'http://titan.uio.no/sites/default/files/thumbnails/image/realfagsbiblioteket_topp_titan.png';
     $parser = new GithubMarkdown();
     $writer = new \XMLWriter();
     $writer->openMemory();
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(true);
     $writer->setIndentString('  ');
     $writer->startElement('rss');
     $writer->writeAttribute('version', '2.0');
     $writer->writeAttribute('xmlns:media', 'http://search.yahoo.com/mrss/');
     $writer->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
     $writer->writeAttribute('xmlns:dct', 'http://dublincore.org/documents/2012/06/14/dcmi-terms/');
     $writer->writeAttribute('xmlns:itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
     $writer->startElement('channel');
     $writer->writeElement('title', $channelTitle);
     $writer->writeElement('link', $channelUrl);
     $writer->writeElement('description', $channelDescription);
     $writer->writeElement('itunes:subtitle', $channelShortDescription);
     $writer->writeElement('itunes:author', $channelAuthor);
     $writer->writeElement('itunes:summary', $channelDescription);
     $writer->startElement('itunes:owner');
     $writer->writeAttribute('itunes:name', $channelAuthor);
     $writer->writeAttribute('itunes:email', $channelAuthorEmail);
     $writer->writeAttribute('href', 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/feed-til-titan.xml');
     $writer->endElement();
     $writer->startElement('itunes:image');
     $writer->writeAttribute('href', $channelImage);
     $writer->endElement();
     $writer->startElement('atom:link');
     $writer->writeAttribute('rel', 'self');
     $writer->writeAttribute('type', 'application/rss+xml');
     $writer->writeAttribute('href', 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/feed-til-titan.xml');
     $writer->endElement();
     $lastModified = Carbon::createFromDate(2000, 1, 1);
     foreach (Recording::with('presentation', 'presentation.event')->orderBy('recorded_at', 'desc')->get() as $video) {
         if (!$video->presentation) {
             continue;
         }
         $event = $video->presentation->event;
         if (count($event->presentations) != 1) {
             continue;
         }
         $body = $parser->parse($event->intro);
         $body = str_replace('<hr />', '', $body);
         $primaryResource = null;
         foreach ($event->resources as $resource) {
             if ($resource->filetype == 'image') {
                 $primaryResource = $resource;
             }
         }
         $mp4Url = null;
         $mp4filesize = 0;
         $writer->startElement('item');
         $writer->startElement('guid');
         $writer->writeAttribute('isPermaLink', 'false');
         $writer->writeRaw($event->uuid);
         $writer->endElement();
         //$event->start_date . ' ' . $video->presentation->start_time
         $writer->writeElement('pubDate', $video->presentation->getStartDateTime()->toRssString());
         $writer->writeElement('dct:created', $video->presentation->getStartDateTime()->toIso8601String());
         $writer->writeElement('dct:modified', $event->updated_at->toIso8601String());
         $writer->writeElement('dct:language', $video->language);
         $writer->writeElement('title', $event->title);
         // $writer->writeElement('recordDate', $video->recorded_at);
         // $writer->writeElement('bodyLength', mb_strlen($body));
         $writer->startElement('description');
         $writer->writeCData($body);
         $writer->endElement();
         $content = '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . $video->youtube_id . '" frameborder="0" allowfullscreen></iframe>';
         $writer->startElement('content');
         $writer->writeCData($content);
         $writer->endElement();
         $writer->startElement('media:embed');
         // ???
         $writer->writeAttribute('url', $video->youtubeLink('embed'));
         $writer->endElement();
         if (!is_null($mp4Url)) {
             $writer->startElement('enclosure');
             $writer->writeAttribute('url', $mp4Url);
             $writer->writeAttribute('length', $mp4filesize);
             $writer->writeAttribute('type', 'video/mp4');
         }
         if (!is_null($primaryResource)) {
             $writer->startElement('media:content');
             $writer->writeAttribute('url', $primaryResource->url('webdav'));
             $writer->writeAttribute('width', $primaryResource->width);
             $writer->writeAttribute('height', $primaryResource->height);
             $writer->writeAttribute('type', 'image/jpeg');
             // $writer->writeElement('attribution', $primaryResource->attribution);
             // Se: http://www.rssboard.org/media-rss#media-license
             //$writer->writeElement('media:license', $primaryResource->license);
             $writer->endElement();
         }
         if ($event->updated_at > $lastModified) {
             $lastModified = $event->updated_at;
         }
         $writer->endElement();
     }
     $writer->writeElement('dct:modified', $lastModified->toIso8601String());
     $writer->writeElement('lastBuildDate', $lastModified->toIso8601String());
     $writer->endElement();
     $writer->endDocument();
     echo $writer->outputMemory();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $recordings = Recording::orderBy('recorded_at', 'desc')->get();
     return response()->view('recordings.index', ['recordings' => $recordings]);
 }