55use App \Enums \TaskStatus ;
66use App \Models \Series ;
77use App \Models \SubTask ;
8- use App \Models \Video ;
98use App \Services \TaskService ;
109use Illuminate \Bus \Batchable ;
1110use Illuminate \Bus \Queueable ;
@@ -84,6 +83,11 @@ private function verifyFolders() {
8483 $ error = false ;
8584 $ index = 0 ;
8685
86+ $ this ->folders ->load ([
87+ 'series ' ,
88+ 'videos.metadata ' ,
89+ ]);
90+
8791 foreach ($ this ->folders as $ folder ) {
8892 try {
8993 $ stored = [];
@@ -94,22 +98,25 @@ private function verifyFolders() {
9498 $ stored = $ series ->toArray ();
9599
96100 // if (is_null($series->episodes)) {
97- $ changes ['episodes ' ] = Video:: where ( ' folder_id ' , $ folder ->id ) ->count ();
101+ $ changes ['episodes ' ] = $ folder ->videos ->count ();
98102 // }
99103
104+ $ changes ['primary_media_type ' ] = $ folder ->primary_media_type ;
105+
100106 if (is_null ($ series ->title )) {
101107 $ changes ['title ' ] = $ folder ->name ;
102108 }
103109
104110 if (isset ($ series ->thumbnail_url ) && ! strpos ($ series ->thumbnail_url , str_replace ('http:// ' , '' , str_replace ('https:// ' , '' , config ('api.app_url ' ))))) {
105111 $ thumbnailResult = $ this ->getThumbnailAsFile ($ series ->thumbnail_url , explode ('/ ' , $ series ->composite_id ?? 'unsorted/unsorted ' )[0 ] . '/ ' . basename ($ series ->id ));
106112 if ($ thumbnailResult ) {
113+ $ changes ['raw_thumbnail_url ' ] = $ series ->thumbnail_url ;
107114 $ changes ['thumbnail_url ' ] = $ thumbnailResult ;
108- dump ('got thumbnail for ' . $ series ->id . ' at ' . $ thumbnailResult );
115+ dump ('got thumbnail for ' . $ series ->id . ' at ' . $ thumbnailResult . ' from ' . $ changes [ ' raw_thumbnail_url ' ] );
109116 }
110117 }
111118
112- $ totalSize = $ series -> folder ->total_size ;
119+ $ totalSize = $ folder ->total_size ;
113120 if ($ stored ['total_size ' ] !== $ totalSize ) {
114121 $ changes ['total_size ' ] = $ totalSize ;
115122 }
@@ -140,7 +147,7 @@ private function verifyFolders() {
140147 return 'No Changes Found ' ;
141148 }
142149
143- Series::upsert ($ transactions , 'id ' , ['folder_id ' , 'title ' , 'episodes ' , 'thumbnail_url ' , 'total_size ' ]);
150+ Series::upsert ($ transactions , 'id ' , ['folder_id ' , 'title ' , 'episodes ' , 'thumbnail_url ' , 'raw_thumbnail_url ' , ' total_size ' , ' primary_media_type ' ]);
144151
145152 $ summary = 'Updated ' . count ($ transactions ) . ' folders from id ' . ($ transactions [0 ]['folder_id ' ]) . ' to ' . ($ transactions [count ($ transactions ) - 1 ]['folder_id ' ]);
146153 dump ($ summary );
0 commit comments