From f543da5b5ddc9aa90dc6f7cd4cce800e0288e1a9 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Tue, 14 Dec 2021 20:12:51 +0530 Subject: [PATCH] short url for links --- .../helpers/video_grabber_helper.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/api/application/helpers/video_grabber_helper.php b/api/application/helpers/video_grabber_helper.php index 55017888..3a51819e 100644 --- a/api/application/helpers/video_grabber_helper.php +++ b/api/application/helpers/video_grabber_helper.php @@ -23,9 +23,11 @@ class video_grabber_helper $result_data = array(); $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pdid and isactive = 1"; $video_info = $CI->db->query($query); + // print_r($video_info->result_array());die(); if($video_info->num_rows()) { $video_info = $video_info->result_array(); + $date_of_creation = date('Ymd'); // $uri = url_shortener::url_shorten($pdid,$random_string); //print_r($video_info);die(); foreach ($video_info as $key => $value) @@ -33,21 +35,27 @@ class video_grabber_helper $video_name = $value['composition_id'].'.mp4'; if($value['is_uploaded']){$video_name = $value['composition_id'];} $file_name = $video_name; - // $get_url = "127.0.0.1:5000?sh_url?url=".$video_name; - // if($get_url['datastatus'] == 200 ){ - // $shorten_url = $get_url['data']; - // }else{ $shorten_url = ''; } - // $date_of_creation = date('Ymd'); - // $shorten_url = custom_encryption::encode( 'vdo/'.$date_of_creation.'/'.$pdid.'/'.$value['composition_id']); - // $shorten_url = PDF_ATTACHEMENT_URL.$shorten_url; - // $shorten_url = (!empty($uri['vdo']) && ($uri[$key]['video_name'] = $value['composition_id'])) ? PDF_ATTACHEMENT_URL.$uri['vdo'][$key]['url'] : ""; if($value['s3_copied']) { $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$file_name; $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+7 days'); + + + if($value['short_link_created_date'] == NULL)//make short url entry in links file + { + $shortURL = 'https://lkt.pdgenie.com/' . substr($video_name,0,6); + $localEncryptedURL = PDF_ATTACHEMENT_URL . custom_encryption::encode( 'vdo/'.$date_of_creation.'/'.$pdid.'/'.$value['composition_id']); + $file = "/data/web/shortlink/links.txt"; + $concatinated_url = $shortURL." ". $localEncryptedURL; + $myfile = file_put_contents($file, $concatinated_url.PHP_EOL , FILE_APPEND | LOCK_EX); - $result_data[] = array('video_name' => $video_name,'s3_url' => $singed_uri,'url'=>$singed_uri,'status' => $value['twilo_status'],'room_id' => $value['room_id'],'id' => $value['video_room_info_id']); + //update short_link_created_date in DB + $CI->db->where('video_room_info_id =',$value['video_room_info_id']); + $CI->db->update(VIDEO_ROOM_INFO, array('short_link_created_date' => date('Y-m-d H:i:s'))); + + } + $result_data[] = array('video_name' => $video_name,'s3_url' => $singed_uri,'url'=>$shortURL,'status' => $value['twilo_status'],'room_id' => $value['room_id'],'id' => $value['video_room_info_id']); } else { @@ -70,10 +78,6 @@ class video_grabber_helper $affectedRows = $CI->db->affected_rows(); return (($affectedRows > 0 ) ? "Deleted successfully" : "Fail to Delete"); } - - - - }