/** * Shows an index of existings recordings * * @return \Illuminate\Http\Response */ public function indexByAgent(Request $request) { $agentNumber = $request->input('agentNumber'); $agentNumberInE164Format = '+' . $agentNumber; $agent = Agent::where(['phone_number' => $agentNumberInE164Format])->firstOrFail(); $allRecordings = Recording::where(['agent_id' => $agent->id])->get(); return response()->view('recordings.index', ['recordings' => $allRecordings, 'agent' => $agent]); }
public static function get($room) { //get all servers meeting existed and check for recordings $bbb_servers = $room->meetings()->groupBy('bbb_server')->get(['bbb_server']); $recordings = array(); foreach ($bbb_servers as $bbb_server) { $bbb = new BigBlueButton($bbb_server->bbb_server); //if server is not up do not bring recordings and continue to next server if (!$bbb->isUp()) { continue; } $recordingsParams = array('meetingId' => $room->bbb_meeting_id); $result = $bbb->getRecordingsWithXmlResponseArray($recordingsParams); $isOwner = roomController::checkOwner($room); foreach ($result as $recording) { if ($recording['playbackFormatUrl'] != null) { $duration_sec = $recording['endTime'] - $recording['startTime']; //create download url $parse_url = parse_url($recording['playbackFormatUrl']); $download_url = 'http://' . $parse_url['host'] . '/playback/presentation/download/' . $recording['recordId'] . '.zip'; $duration = gmdate("H:i:s", substr($duration_sec, 0, -3)); //find if we know recording $rec_query = Recording::where('rid', $recording['recordId'])->first(); //if we dont just save if (!$rec_query) { $rec_ins = new Recording(); $rec_ins->rid = $recording['recordId']; $rec_ins->published = 0; $rec_ins->keep = 0; $rec_ins->bbb_server_id = $bbb->id; $rec_ins->owner = $room->owner; $rec_ins->save(); //new recording show only to owner if ($isOwner) { $recordings[] = array('id' => $recording['recordId'], 'url' => $recording['playbackFormatUrl'], 'time' => date('d/m/Y H:i', substr($recording['startTime'], 0, -3)), 'duration' => $duration, 'time_real' => $recording['startTime'], 'download_url' => $download_url, 'server_id' => $bbb->id, 'keep' => false, 'portal_id' => $rec_ins->id, 'published' => false); } } else { if ($rec_query->published || $isOwner) { $recordings[] = array('id' => $recording['recordId'], 'url' => $recording['playbackFormatUrl'], 'time' => date('d/m/Y H:i', substr($recording['startTime'], 0, -3)), 'duration' => $duration, 'time_real' => $recording['startTime'], 'download_url' => $download_url, 'server_id' => $bbb->id, 'keep' => $rec_query->keep, 'portal_id' => $rec_query->id, 'published' => $rec_query->published); } } } } } if (!empty($recordings)) { usort($recordings, function ($a, $b) { return $b['time_real'] - $a['time_real']; }); return $recordings; } else { return null; } }
/** * 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 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); }