Skip to content

Commit b78ff08

Browse files
v1.3 - Use temp download location
#299 - Resolves this for radarr
1 parent 8d9271f commit b78ff08

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

radarr/Extras.bash

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
scriptVersion="1.2"
2+
scriptVersion="1.3"
33
arrEventType="$radarr_eventtype"
44
arrItemId=$radarr_movie_id
55
tmdbApiKey="3b7751e3179f796565d88fdb2fcdf426"
@@ -175,13 +175,7 @@ do
175175
fi
176176
fi
177177

178-
if [ ! -d "$finalPath" ]; then
179-
mkdir -p "$finalPath"
180-
chmod 777 "$finalPath"
181-
fi
182-
183-
184-
if [ -f "$finalPath/$finalFileName.mkv" ]; then
178+
if [ -f "$finalPath/$finalFileName.mkv" ]; then
185179
log "$itemTitle :: $i of $tmdbViscriptsdeosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ($tmdbExtraKey) :: Already Downloaded, skipping..."
186180
if [ "$extrasSingle" == "true" ]; then
187181
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: Finished processing single trailer download"
@@ -196,29 +190,50 @@ do
196190
fi
197191

198192
videoLanguages="$(echo "$extrasLanguages" | sed "s/-[[:alpha:]][[:alpha:]]//g")"
193+
194+
tempFolder="/config/extended/temp"
195+
if [ -d "$tempFolder" ]; then
196+
rm -rf "$tempFolder"
197+
sleep 0.01
198+
fi
199+
200+
if [ ! -d "$tempFolder" ]; then
201+
mkdir -p "$tempFolder"
202+
fi
199203

200204
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ($tmdbExtraKey) :: Downloading (yt-dlp :: $videoFormat)..."
201205
if [ ! -z "$cookiesFile" ]; then
202-
yt-dlp -f "$videoFormat" --no-video-multistreams --cookies "$cookiesFile" -o "$finalPath/$finalFileName" --write-sub --sub-lang $videoLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass $ytdlpExtraOpts "https://www.youtube.com/watch?v=$tmdbExtraKey"
206+
yt-dlp -f "$videoFormat" --no-video-multistreams --cookies "$cookiesFile" -o "$tempFolder/$finalFileName" --write-sub --sub-lang $videoLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass $ytdlpExtraOpts "https://www.youtube.com/watch?v=$tmdbExtraKey"
203207
else
204-
yt-dlp -f "$videoFormat" --no-video-multistreams -o "$finalPath/$finalFileName" --write-sub --sub-lang $videoLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass $ytdlpExtraOpts "https://www.youtube.com/watch?v=$tmdbExtraKey"
208+
yt-dlp -f "$videoFormat" --no-video-multistreams -o "$tempFolder/$finalFileName" --write-sub --sub-lang $videoLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass $ytdlpExtraOpts "https://www.youtube.com/watch?v=$tmdbExtraKey"
205209
fi
206-
if [ -f "$finalPath/$finalFileName.mkv" ]; then
210+
if [ -f "$tempFolder/$finalFileName.mkv" ]; then
207211
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ($tmdbExtraKey) :: Compete"
208-
chmod 666 "$finalPath/$finalFileName.mkv"
209212
else
210213
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ($tmdbExtraKey) :: ERROR :: Download Failed"
211214
continue
212215
fi
213216

214-
if python3 /usr/local/sma/manual.py --config "/config/extended/sma.ini" -i "$finalPath/$finalFileName.mkv" -nt; then
217+
if python3 /usr/local/sma/manual.py --config "/config/extended/sma.ini" -i "$tempFolder/$finalFileName.mkv" -nt; then
215218
sleep 0.01
216219
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle :: Processed with SMA..."
217220
rm /usr/local/sma/config/*log*
218221
else
219222
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle :: ERROR :: SMA Processing Error"
220223
rm "$finalPath/$finalFileName.mkv"
221-
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle :: INFO: deleted: $finalPath/$finalFileName.mkv"
224+
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle :: INFO: deleted: $tempFolder/$finalFileName.mkv"
225+
fi
226+
227+
if [ ! -d "$finalPath" ]; then
228+
mkdir -p "$finalPath"
229+
chmod 777 "$finalPath"
230+
fi
231+
232+
if [ -f "$tempFolder/$finalFileName.mkv" ]; then
233+
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle :: Moving file to final destination"
234+
mv "$tempFolder/$finalFileName.mkv" "$finalPath/$finalFileName.mkv"
235+
chmod 666 "$finalPath/$finalFileName.mkv"
236+
rm -rf "$tempFolder"
222237
fi
223238

224239
updatePlex="true"

0 commit comments

Comments
 (0)