@@ -549,11 +549,11 @@ public static function getTitleFromLinkWithPytube($video_url)
549549
550550 $ downloadWithPytubeFilename = 'video_download_ ' . md5 ($ video_url );
551551 $ metadataFile = "{$ global ['systemRootPath ' ]}videos/pytube/ {$ downloadWithPytubeFilename }/metadata.json " ;
552- if (!file_exists ($ metadataFile )){
552+ if (!file_exists ($ metadataFile )) {
553553 $ response = self ::downloadWithPytube ($ video_url , $ downloadWithPytubeFilename , 'metadata ' );
554554 }
555555
556- if (file_exists ($ metadataFile )){
556+ if (file_exists ($ metadataFile )) {
557557 $ content = file_get_contents ($ metadataFile );
558558 $ json = json_decode ($ content );
559559 return $ json ->title ;
@@ -567,11 +567,11 @@ public static function getDescriptionFromLinkWithPytube($video_url)
567567
568568 $ downloadWithPytubeFilename = 'video_download_ ' . md5 ($ video_url );
569569 $ metadataFile = "{$ global ['systemRootPath ' ]}videos/pytube/ {$ downloadWithPytubeFilename }/metadata.json " ;
570- if (!file_exists ($ metadataFile )){
570+ if (!file_exists ($ metadataFile )) {
571571 $ response = self ::downloadWithPytube ($ video_url , $ downloadWithPytubeFilename , 'metadata ' );
572572 }
573573
574- if (file_exists ($ metadataFile )){
574+ if (file_exists ($ metadataFile )) {
575575 $ content = file_get_contents ($ metadataFile );
576576 $ json = json_decode ($ content );
577577 return $ json ->description ;
@@ -585,11 +585,11 @@ public static function getDurationFromLinkWithPytube($video_url)
585585
586586 $ downloadWithPytubeFilename = 'video_download_ ' . md5 ($ video_url );
587587 $ metadataFile = "{$ global ['systemRootPath ' ]}videos/pytube/ {$ downloadWithPytubeFilename }/metadata.json " ;
588- if (!file_exists ($ metadataFile )){
588+ if (!file_exists ($ metadataFile )) {
589589 $ response = self ::downloadWithPytube ($ video_url , $ downloadWithPytubeFilename , 'metadata ' );
590590 }
591591
592- if (file_exists ($ metadataFile )){
592+ if (file_exists ($ metadataFile )) {
593593 $ content = file_get_contents ($ metadataFile );
594594 $ json = json_decode ($ content );
595595 return $ json ->duration_seconds ;
@@ -603,11 +603,11 @@ public static function getThumbsFromLinkWithPytube($video_url, $returnFileName =
603603
604604 $ downloadWithPytubeFilename = 'video_download_ ' . md5 ($ video_url );
605605 $ File = "{$ global ['systemRootPath ' ]}videos/pytube/ {$ downloadWithPytubeFilename }/thumbs.jpg " ;
606- if (!file_exists ($ File )){
606+ if (!file_exists ($ File )) {
607607 $ response = self ::downloadWithPytube ($ video_url , $ downloadWithPytubeFilename , 'thumbnail ' );
608608 }
609609
610- if (file_exists ($ File )){
610+ if (file_exists ($ File )) {
611611 if ($ returnFileName ) {
612612 return $ File ;
613613 } else {
@@ -624,7 +624,7 @@ public static function downloadWithPytube($video_url, $filename, $action = 'vide
624624 global $ global ;
625625 $ video_url = str_replace (array ('\\' , "' " ), array ('' , '' ), $ video_url );
626626 $ pythonScript = $ global ['systemRootPath ' ] . "objects/youtube.py " ;
627- $ command = escapeshellcmd ("python3 $ pythonScript " . escapeshellarg ($ video_url ) . " " . escapeshellarg ($ filename ). " {$ action }" );
627+ $ command = escapeshellcmd ("python3 $ pythonScript " . escapeshellarg ($ video_url ) . " " . escapeshellarg ($ filename ) . " {$ action }" );
628628 _error_log ("downloadWithPytube( $ video_url, $ filename) " . $ command );
629629 exec ($ command , $ output , $ return_var );
630630
@@ -709,18 +709,18 @@ public static function downloadFile($queue_id)
709709 if (!empty ($ q ->getVideoDownloadedLink ())) {
710710 $ videoURL = $ q ->getVideoDownloadedLink ();
711711
712- if (isFTPURL ($ videoURL )){
712+ if (isFTPURL ($ videoURL )) {
713713 require_once __DIR__ . '/FTPDownloader.php ' ;
714714 FTPDownloader::copy ($ videoURL , $ obj ->pathFileName );
715715 $ obj ->error = !file_exists ($ obj ->pathFileName );
716- }else {
716+ } else {
717717
718718 $ downloadWithPytubeFilename = '' ;
719719 if (self ::isPythonAndPytubeInstalled () && isYouTubeUrl ($ videoURL )) {
720720 $ downloadWithPytubeFilename = 'video_download_ ' . $ queue_id ;
721721 $ response = self ::downloadWithPytube ($ videoURL , $ downloadWithPytubeFilename );
722722 }
723- if (empty ($ downloadWithPytubeFilename ) || $ response ->error ){
723+ if (empty ($ downloadWithPytubeFilename ) || $ response ->error ) {
724724 //begin youtube-dl downloading and symlink it to the video temp file
725725 $ response = static ::getYoutubeDl ($ videoURL , $ queue_id , $ obj ->pathFileName );
726726 if (!empty ($ response )) {
@@ -731,11 +731,10 @@ public static function downloadFile($queue_id)
731731 _error_log ("downloadFile:getYoutubeDl ERROR queue_id = {$ queue_id }" );
732732 $ obj ->error = false ;
733733 }
734- }else {
734+ } else {
735735 $ obj ->pathFileName = "{$ global ['systemRootPath ' ]}videos/pytube/ {$ downloadWithPytubeFilename }/video.mp4 " ;
736736 }
737737 }
738-
739738 } else {
740739 _error_log ("downloadFile: not using getYoutubeDl " );
741740 //symlink the downloaded file to the video temp file ($obj-pathFileName)
@@ -800,13 +799,13 @@ public static function getYoutubeDl($videoURL, $queue_id, $destinationFile, $add
800799 global $ global ;
801800 $ videoURL = str_replace ("' " , '' , $ videoURL );
802801 $ videoURL = trim ($ videoURL );
803- if (strpos ($ videoURL , "/ " ) === 0 ){
804- if (!file_exists ($ videoURL )){
802+ if (strpos ($ videoURL , "/ " ) === 0 ) {
803+ if (!file_exists ($ videoURL )) {
805804 $ videoURL2 = str_replace (' ' , '- ' , $ videoURL );
806- if (file_exists ($ videoURL2 )){
805+ if (file_exists ($ videoURL2 )) {
807806 $ videoURL = $ videoURL2 ;
808807 return _rename ($ videoURL , $ destinationFile ) ? $ destinationFile : $ videoURL ;
809- }else {
808+ } else {
810809 _error_log ("getYoutubeDl: Local file does not exists $ videoURL " . json_encode (debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS )));
811810 return false ;
812811 }
@@ -1284,7 +1283,7 @@ public static function run($try = 0)
12841283 {
12851284 global $ global , $ advancedCustom ;
12861285 $ maxTries = 4 ;
1287- $ lockFile = sys_get_temp_dir () . '/encoder_run. ' . md5 ($ global ['webSiteRootURL ' ]). '.lock ' ;
1286+ $ lockFile = sys_get_temp_dir () . '/encoder_run. ' . md5 ($ global ['webSiteRootURL ' ]) . '.lock ' ;
12881287
12891288 // Check if the lock file exists
12901289 if (file_exists ($ lockFile )) {
@@ -1367,7 +1366,14 @@ public static function run($try = 0)
13671366 $ encoder ->setStatus (Encoder::STATUS_ENCODING );
13681367 $ encoder ->save ();
13691368 self ::run (0 );
1370- self ::sendImages ($ objFile ->pathFileName , $ return_vars , $ encoder );
1369+ $ response = self ::sendImages ($ objFile ->pathFileName , $ return_vars , $ encoder );
1370+ if (!empty ($ response ->doNotRetry )) {
1371+ $ obj ->msg = "sendToStreamer timeout. Not retrying " ;
1372+ _error_log ("Encoder::run: Encoder Run: " . json_encode ($ obj ));
1373+ self ::setStatusError ($ encoder ->getId (), $ obj ->msg );
1374+ unlink ($ lockFile ); // Remove the lock file before returning
1375+ return false ;
1376+ }
13711377 $ code = new Format ($ encoder ->getFormats_id ());
13721378 $ resp = $ code ->run ($ objFile ->pathFileName , $ encoder ->getId ());
13731379 if (!empty ($ resp ->error )) {
@@ -2813,7 +2819,7 @@ public static function getTitleFromLink($link, $streamers_id, $addOauthFromProvi
28132819 {
28142820 if (self ::isPythonAndPytubeInstalled () && isYouTubeUrl ($ link )) {
28152821 $ resp = self ::getTitleFromLinkWithPytube ($ link );
2816- if (!empty ($ resp )){
2822+ if (!empty ($ resp )) {
28172823 return array ('error ' => false , 'output ' => $ resp );
28182824 }
28192825 }
@@ -2846,7 +2852,7 @@ public static function getDurationFromLink($link, $streamers_id, $addOauthFromPr
28462852 {
28472853 if (self ::isPythonAndPytubeInstalled () && isYouTubeUrl ($ link )) {
28482854 $ resp = self ::getDurationFromLinkWithPytube ($ link );
2849- if (!empty ($ resp )){
2855+ if (!empty ($ resp )) {
28502856 return static ::parseSecondsToDuration ($ resp );
28512857 }
28522858 }
@@ -2873,7 +2879,7 @@ public static function getThumbsFromLink($link, $streamers_id, $returnFileName =
28732879 {
28742880 if (self ::isPythonAndPytubeInstalled () && isYouTubeUrl ($ link )) {
28752881 $ resp = self ::getThumbsFromLinkWithPytube ($ link , $ returnFileName );
2876- if (!empty ($ resp )){
2882+ if (!empty ($ resp )) {
28772883 return $ resp ;
28782884 }
28792885 }
@@ -2926,7 +2932,7 @@ public static function getDescriptionFromLink($link, $streamers_id, $addOauthFro
29262932
29272933 if (self ::isPythonAndPytubeInstalled () && isYouTubeUrl ($ link )) {
29282934 $ resp = self ::getDescriptionFromLinkWithPytube ($ link );
2929- if (!empty ($ resp )){
2935+ if (!empty ($ resp )) {
29302936 return $ resp ;
29312937 }
29322938 }
@@ -2971,7 +2977,7 @@ public static function getYouTubeDLCommand($addOauthFromProvider = '', $streamer
29712977 {
29722978 global $ global ;
29732979 $ cacheDir = '/var/www/.cache/ ' ;
2974- if (!is_dir ($ cacheDir )){
2980+ if (!is_dir ($ cacheDir )) {
29752981 @mkdir ($ cacheDir );
29762982 }
29772983
0 commit comments