From f96f299e9774522b641b1c2f03ede2bd97eb6a75 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Wed, 3 Nov 2021 20:33:22 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Gros=20changements=20:=20automatisation=20d?= =?UTF-8?q?u=20processus=20,=20plus=20besoin=20de=20modifier=20les=20comma?= =?UTF-8?q?ndes=20manuellement.=20Il=20suffit=20de=20choisir=20le=20nb=20d?= =?UTF-8?q?e=20SRT=20externes=20ou=20internes=20au=20d=C3=A9but=20du=20scr?= =?UTF-8?q?ipt=20et=20de=20bien=20remplir=20les=20champs.=20Modification?= =?UTF-8?q?=20du=20chemin=20d'acc=C3=A8s=20avec=20des=20`"=20`"=20pour=20e?= =?UTF-8?q?ncadrer=20le=20chemin=20au=20cas-o=C3=B9=20il=20y=20est=20des?= =?UTF-8?q?=20espaces.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e one MKV Audio with another video MKV.ps1 | 336 ++++++++++-------- 1 file changed, 179 insertions(+), 157 deletions(-) diff --git a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 index fee589e..075ac4a 100644 --- a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 +++ b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 @@ -24,8 +24,8 @@ ## ## ##============================================================================================== -#Set MKVMerge.exe Path -$MKVMerge = 'H:\z_MKV\mkvtoolnix\mkvmerge.exe' +# Set MKVMerge.exe Path +$MKVMerge = "`"H:\z_MKV\mkvtoolnix\mkvmerge.exe`"" #Set Source and Target directories (Don't put an \ at the end) $sourceDirectory_1 = "PATH_TO_SOURCE_1" @@ -33,8 +33,10 @@ $sourceDirectory_2 = "PATH_TO_SOURCE_2" $destinationDirectory = "PATH_TO_DESTINATION" # Rename output file with this settings : -$chain_to_search = '(.*) - S(\d*)E(\d*) - (.*)x264(.*)' -$chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded' +$chain_to_search = '(.*).S(\d*)E(\d*).(.*)H264(.*)' +#$chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).720p.(.*)x264(.*)' +$chain__to_replace = '$1 (2003) - S$2E$3 - $4x265-10bits$5--Reencoded' + # The filenames must be like : blabla.S00E00.blabla.H.264.blabla # They will be renamed to : blabla - S00E00 - blabla.x265-10bits.blabla--Reencoded # If you don't want the rename to be made, juste set to '' the variables. @@ -42,27 +44,43 @@ $chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded' # Is there an external subtitle ? Set the number of .SRT (0 - 2) # It's exclusive, no internal SUB will be proceed.. -$NB_External_SUB = 2 +$NB_External_SUB = 0 # Extension without the . $MkvExtension = "mkv" #Set Subtitle Extension (Don't add the . before the extension) -$SubExtension_1 = 'eng.srt' +$SubExtension_1 = 'srt' $SubExtension_2 = 'fre.srt' #If source and destination are the same folder, set this to True, Otherwise let it to "False" $merged_SUFFIX_name = "False" +# Initialization for those 2 variables, do not change them ! +$MKVMerge_sub_param = "" +$MKVMerge_audio_param = "" +# ################## + #### FILE 1 - Keeping all but the video # ================== AUDIO ================== # Track 1 = Audio n°1 # Name and language of Audio Track n°1 -$AudioTrackName_1 = "1:English - DTS-HD MA" +$AudioTrackName_1 = "`"1:English - DDP 5.1`"" $AudioLang_1 = "1:en" $AudioTrack_1_default = "1:yes" -#$file_1_options = "--no-video" # Define track order $track_order = "1:0,0:1" +# $MKVMerge_audio_param = '--language', "$AudioLang_1", '--track-name', "$AudioTrackName_1", '--default-track', "$AudioTrack_1_default" +$MKVMerge_audio_param = "--language $AudioLang_1 --track-name $AudioTrackName_1 --default-track $AudioTrack_1_default" + +# # Track 2 = Audio n°2 +# # Name and language of Audio Track n°2 +# $AudioTrackName_1 = "`"2:English - DDP 5.1`"" +# $AudioLang_1 = "2:en" +# $AudioTrack_1_default = "2:yes" +# # Define track order +# $track_order = "1:0,0:1,0:2" +# $MKVMerge_audio_param += "--language $AudioLang_2 --track-name $AudioTrackName_2 --default-track $AudioTrack_2_default" + ########################################## #### FILE 2 - MKV - Keeping only the video #### $file_2_options = "--no-audio --no-track-tags --no-global-tags" @@ -75,7 +93,7 @@ if ( $NB_External_SUB -ne 0 ) { # ================== SUBTITLES ================== # Track 0 = Sub n°1 to keep # Name and language of Subtitle Track n°0 + Sync Value - $ExtSubTrackName_1 = "0:English - SRT" + $ExtSubTrackName_1 = "`"0:English - SRT`"" $ExtSubTrackLang_1 = "0:eng" $ExtSubTrack_1_default = "0:yes" $ExtSub_charset_1 = "0:UTF-8" @@ -86,7 +104,7 @@ if ( $NB_External_SUB -ne 0 ) { # ================== SUBTITLES ================== # Track 0 = Sub n°1 to keep # Name and language of Subtitle Track n°0 + Sync Value - $ExtSubTrackName_2 = "0:Français - SRT" + $ExtSubTrackName_2 = "`"0:Français - SRT`"" $ExtSubTrackLang_2 = "0:fr" $ExtSubTrack_2_default = "0:no" $ExtSub_charset_2 = "0:UTF-8" @@ -99,25 +117,29 @@ else { # ================== INTERNAL SUBTITLES ================== # Track 2 = Sub n°1 to keep # Name and language of Subtitle Track n°1 + Sync Value - # $SubTrackName_1 = "2:English SDH - SRT" - # $SubTrackLang_1 = "2:en" - # $SubTrack_1_default = "2:yes" - # $sub_charset_1 = "2:UTF-8" + $SubTrackName_1 = "`"2:English - SRT`"" + $SubTrackLang_1 = "2:en" + $SubTrack_1_default = "2:yes" + $sub_charset_1 = "2:UTF-8" # Define track order $track_order += ",0:2" $subtitle_tracks = "2" + # $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default" + $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name $SubTrackName_1 --default-track $SubTrack_1_default" # Track 3 = Sub n°2 to keep # Name and language of Subtitle Track n°1 + Sync Value - $SubTrackName_1 = "3:English SDH - SRT" - $SubTrackLang_1 = "3:eng" - $SubTrack_1_default = "3:yes" - $sub_charset_1 = "3:UTF-8" + # $SubTrackName_1 = "3:English SDH - SRT" + # $SubTrackLang_1 = "3:eng" + # $SubTrack_1_default = "3:yes" + # $sub_charset_1 = "3:UTF-8" # # Define track order # $track_order += ",0:3" # $subtitle_tracks = "3" + # $MKVMerge_sub_param += "--sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name $SubTrackName_2 --default-track $SubTrack_2_default" #### } +## End of part where there is something to change ! ##============================================================================================== # Testing if the Not-Merged folder already exists : if yes, it will be renamed, else it will be created. @@ -139,7 +161,6 @@ If(!(test-path $Path_Folder_NotMerged_1)) { #Move-Item -Path $Path_Folder_NotMerged_2 -Destination "$sourceDirectory\Not-Merged--backup" -Verbose } - #Process $MKV_1_List = Get-ChildItem $sourceDirectory_1 -Filter "*.mkv" | ForEach-Object { $_.FullName } | Sort-Object $Count_1 = $MKV_1_List.count @@ -209,167 +230,153 @@ Foreach ($MKV_1 in $MKV_1_List) { $MKV_2_name = $FormatName_2.Substring(0,$FormatName_2.Length-($MkvExtension.Length+1)) $MKV_2 = $sourceDirectory_2 + "\" + $MKV_2_name + ".$MkvExtension" - if ( $NB_External_SUB -ne 0 ) { - $SRT_1_Name = $MKV_1_name + ".$SubExtension_1" - $SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name - $SRT_2_Name = $MKV_1_name + ".$SubExtension_2" - $SRT_2 = $sourceDirectory_1 + "\" + $SRT_2_name - } # Title for the video track and for the destination file #$VideoTrackName = $MKV_1_name -replace '(.*).S(\d*)E(\d*).(.*)H.264(.*)', '$1 - S$2E$3 - $4x265-10bits$5--Reencoded' $VideoTrackName = $MKV_1_name -replace $chain_to_search, $chain__to_replace + $VideoTrackName = "$VideoTrackName" ######################################################### # Exceptions for some files with other than 2 SRT inside # You must copy paste the default entries set in the begining of this script in the Default section - # switch ($MKV_1_name) - # { - # "FILE-1-blabla" - # { - # # ================== AUDIO ================== - # # Track 1 = Audio n°1 - # # Name and language of Audio Track n°1 - # $AudioTrackName_1 = "1:English - DDP 5.1" - # $AudioLang_1 = "1:en" - # $AudioTrack_1_default = "1:yes" + switch ($MKV_1_name) + { + "Defiance.S03E01E02.720p.The World We Seize.HDTV.X264-DIMENSION" + { + # # ================== AUDIO ================== + # # Track 1 = Audio n°1 + # # Name and language of Audio Track n°1 + # $AudioTrackName_1 = "1:English - DDP 5.1" + # $AudioLang_1 = "1:en" + # $AudioTrack_1_default = "1:yes" - # # Only One subtitle track : n°2 - # $SubTrackName_1 = "3:English SDH - SRT" - # $SubTrackLang_1 = "3:en" - # $SubTrack_1_default = "3:yes" - # $sub_charset_1 = "3:UTF-8" - # # Define track order - # $track_order = "1:0,0:1,0:3" - # # Define subtitles track to keep - # $subtitle_tracks = "3" - # break - # } - # "FILE-2-blabla" - # { - # # Track 1 = Audio n°1 - # # Name and language of Audio Track n°1 - # $AudioTrackName_1 = "1:English - AAC 2.0" - # $AudioLang_1 = "1:en" - # $AudioTrack_1_default = "1:yes" + # # Only One subtitle track : n°2 + # $SubTrackName_1 = "3:English SDH - SRT" + # $SubTrackLang_1 = "3:en" + # $SubTrack_1_default = "3:yes" + # $sub_charset_1 = "3:UTF-8" + # # Define track order + # $track_order = "1:0,0:1,0:3" + # # Define subtitles track to keep + # $subtitle_tracks = "3" - # # Only One subtitle track : n°2 - # $SubTrackName_1 = "2:English - SRT" - # $SubTrackLang_1 = "2:en" - # $SubTrack_1_default = "2:yes" - # $sub_charset_1 = "2:UTF-8" - # # Define track order - # $track_order = "1:0,0:1,0:2" - # # Define subtitles track to keep - # $subtitle_tracks = "2" - # break - # } - # #Default state - # Default - # { - # # If not an exception, we don't want to modify the variables - # $SubTrackName_1 = "3:English SDH - SRT" - # $SubTrackLang_1 = "3:eng" - # $SubTrack_1_default = "3:yes" - # $sub_charset_1 = "3:UTF-8" - # # Define track order - # $track_order = "1:0,0:1,0:3" - # # Define subtitles track to keep - # $subtitle_tracks = "3" - # break - # } - # } + $VideoTrackName = "Defiance - S03E01-E02 - 720p.HDTV.x265-10bits-DIMENSION--Reencoded" + break + } + "Defiance.S02S02E12-E13.720p.All Things Must Pass--I Almost Prayed.HDTV.x264-KILLERS" + { + # # Track 1 = Audio n°1 + # # Name and language of Audio Track n°1 + # $AudioTrackName_1 = "1:English - AAC 2.0" + # $AudioLang_1 = "1:en" + # $AudioTrack_1_default = "1:yes" + + # # Only One subtitle track : n°2 + # $SubTrackName_1 = "2:English - SRT" + # $SubTrackLang_1 = "2:en" + # $SubTrack_1_default = "2:yes" + # $sub_charset_1 = "2:UTF-8" + # # Define track order + # $track_order = "1:0,0:1,0:2" + # # Define subtitles track to keep + # $subtitle_tracks = "2" + + $VideoTrackName = "Defiance - S02S02E12-E13 - PROPER.720p.HDTV.x265-10bits-KILLERS--Reencoded" + + break + } + #Default state + Default + { + # If not an exception, we don't want to modify the variables + # $SubTrackName_1 = "3:English SDH - SRT" + # $SubTrackLang_1 = "3:eng" + # $SubTrack_1_default = "3:yes" + # $sub_charset_1 = "3:UTF-8" + # # Define track order + # $track_order = "1:0,0:1,0:3" + # # Define subtitles track to keep + # $subtitle_tracks = "3" + break + } + } ######################################################### - - - - #Set Output File Name - #$Output = $Name + '___MERGED' + '.mkv' + # Set Output File Name If ($merged_SUFFIX_name -eq "True") { $Output = $destinationDirectory + "\" + $VideoTrackName + '___MERGED' + '.mkv' + $Output = "`"$Output`"" } elseif ($merged_SUFFIX_name -eq "False") { - $Output = $destinationDirectory + "\" + $VideoTrackName + '.mkv' + # $Output = $destinationDirectory + "\" + $VideoTrackName + '.mkv' + $Output = "$destinationDirectory" + "\" + "$VideoTrackName" + ".mkv" + $Output = "`"$Output`"" } else { - write-host "Error in the value of the merged_SUFFIX_name variable. Current value = $merged_SUFFIX_name" -foreground "red" - write-host "Should be set to True or False.`nScript is exiting now..." -foreground "white" + write-host "Error in the value of the merged_SUFFIX_name variable. Current value = $merged_SUFFIX_name" -ForegroundColor "red" + write-host "Should be set to True or False.`nScript is exiting now..." -ForegroundColor "white" Exit } - # write-host "Output file will be :" -foreground "white" - # write-host "$Output" - # write-host "--" + # write-host "Output file will be :" -ForegroundColor "white" + # write-host "$Output" -ForegroundColor "white" + # write-host "--" -ForegroundColor "white" - #Execute - # Keep Audio/Subtitles/tags from MKV_1 + Only video from MKV_2 -<# Command to edit -& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" ---no-video ---language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" ---sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" ---sub-charset "$sub_charset_2" --language "$SubTrackLang_2" --track-name "$SubTrackName_2" --default-track "$SubTrack_2_default" -"$MKV_1" --no-audio --no-track-tags --no-global-tags ---language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" -"$MKV_2" -#> Write-Host "" -ForegroundColor "black" -BackgroundColor "white" Write-Host "Traitement du fichier n° $compteur / $Count_1..." -ForegroundColor "black" -BackgroundColor "white" Write-Host "" -ForegroundColor "black" -BackgroundColor "white" - if ( $NB_External_SUB -eq 1 ) { - <# Command to edit - & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" - --no-video --no-subtitles - --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" - --language "$AudioLang_2" --track-name "$AudioTrackName_2" --default-track "$AudioTrack_2_default" - - "$MKV_1" - -no-audio --no-track-tags --no-global-tags - --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" - "$MKV_2" - --sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" - "$SRT_1" - #> - - & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1" - } - elseif ( $NB_External_SUB -eq 2 ) { - <# Command to edit - & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" - --no-video --no-subtitles - --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" - --language "$AudioLang_2" --track-name "$AudioTrackName_2" --default-track "$AudioTrack_2_default" - - "$MKV_1" - --no-audio --no-track-tags --no-global-tags - --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" - "$MKV_2" - --sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" - "$SRT_1" - --sub-charset "$Extsub_charset_2" --language "$ExtSubTrackLang_2" --track-name "$ExtSubTrackName_2" --default-track "$ExtSubTrack_2_default" - "$SRT_2" - #> - - # Write-Host "Commande qui va être lancée : " -foreground "green" - # Write-Host "MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --language "$AudioLang_2" --track-name "$AudioTrackName_2" --default-track "$AudioTrack_2_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$ExtSub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1"" -foreground "green" - - - & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$ExtSub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1" --sub-charset "$ExtSub_charset_2" --language "$ExtSubTrackLang_2" --track-name "$ExtSubTrackName_2" --default-track "$ExtSubTrack_2_default" "$SRT_2" + if ( $NB_External_SUB -ne 0 ) { - } + # First external SRT to include + $SRT_1_Name = $MKV_1_name + ".$SubExtension_1" + $SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name + $MKVMerge_param_start = "---output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --no-video --no-subtitles" + $MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`"" + $MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`"" + + $MKVMerge_param_srt1 = "--sub-charset $Extsub_charset_1 --language $ExtSubTrackLang_1 --track-name `"$ExtSubTrackName_1`" --default-track $ExtSubTrack_1_default `"$SRT_1`"" + + $MKVMerge_param_srt_all = "$MKVMerge_param_srt1" + + if ( $NB_External_SUB -ne 0 ) { + # Second external SRT to include + $SRT_2_Name = $MKV_1_name + ".$SubExtension_2" + $SRT_2 = $sourceDirectory_1 + "\" + $SRT_2_name + + $MKVMerge_param_srt2 = "--sub-charset $Extsub_charset_2 --language $ExtSubTrackLang_2 --track-name `"$ExtSubTrackName_2`" --default-track $ExtSubTrack_2_default `"$SRT_2`"" + $MKVMerge_param_srt_all += " $MKVMerge_param_srt2" + } + + $MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_mkv2 $MKVMerge_param_srt_all" + + } else { # INTERNAL SUB to keep + + $MKVMerge_param_start = "--output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video" + $MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`"" + $MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`"" - # two subtiles to keep : - #& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" --sub-charset "$sub_charset_2" --language "$SubTrackLang_2" --track-name "$SubTrackName_2" --default-track "$SubTrack_2_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2" - - # Only one subtitles to keep - & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2" - + $MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_mkv2" + # ################## + # Debug + # Write-Host "$MKVMerge_param_start" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "$MKVMerge_audio_param" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "$MKVMerge_sub_param" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "$MKVMerge_param_mkv2" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "$MKVMerge_param_all" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "Commande qui sera lancée :" -ForegroundColor "black" -BackgroundColor "DarkGray" + # Write-Host "& $MKVMerge" "$MKVMerge_param_all" -ForegroundColor "black" -BackgroundColor "DarkGray" + # ################## } + # Last step to command construction + $command = "& $MKVMerge $MKVMerge_param_all" + # Launch begin... + Invoke-Expression $command + Write-Host "" -ForegroundColor "black" -BackgroundColor "white" Write-Host "Fin du traitement du fichier n° $compteur / $Count_1." -ForegroundColor "black" -BackgroundColor "white" Write-Host "" -ForegroundColor "black" -BackgroundColor "white" @@ -383,21 +390,36 @@ Foreach ($MKV_1 in $MKV_1_List) { Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose Move-Item -Path $MKV_2 -Destination $Path_Folder_NotMerged_2 -Verbose - if ( $NB_External_SUB -ne 0 ) { Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose if ( $NB_External_SUB -eq 2 ) { Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose } } - - - # Renaming the output file is not necessary if the output filename doesn't have __MERGED in it - #Rename-Item -Path $Output -NewName $MKV -Verbose - - } Else { + } + Else { write-host "File NON-EXISTANT - $Output" -foreground "red" "File NON-EXISTANT - $Output" | Out-File "$destinationDirectory\Errors.txt" -Append } $compteur++ -} \ No newline at end of file +} + + + +# ############################## +# Command History +# +# internal Subtitles : +# two subtiles to keep : +#& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" --sub-charset "$sub_charset_2" --language "$SubTrackLang_2" --track-name "$SubTrackName_2" --default-track "$SubTrack_2_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2" + +# Only one subtitles to keep +# & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2" +# +# +# External Subtitles +# # 1 SRT +# & $MKVMerge --output "$Output" --title "$VideoTrackName" --track-order "$track_order" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1" +# +# # 2 SRTs +# & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$ExtSub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1" --sub-charset "$ExtSub_charset_2" --language "$ExtSubTrackLang_2" --track-name "$ExtSubTrackName_2" --default-track "$ExtSubTrack_2_default" "$SRT_2" \ No newline at end of file From c8eca5736ef09b288ceacf9f82542e7af8e27459 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Thu, 4 Nov 2021 17:53:15 +0100 Subject: [PATCH 2/8] =?UTF-8?q?Petites=20am=C3=A9liorations=20D=C3=A9place?= =?UTF-8?q?ment=20param=C3=A9trable=20des=20fichiers=20merg=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e one MKV Audio with another video MKV.ps1 | 116 +++++++++++------- 1 file changed, 71 insertions(+), 45 deletions(-) diff --git a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 index 075ac4a..a0ab6bb 100644 --- a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 +++ b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 @@ -24,8 +24,11 @@ ## ## ##============================================================================================== +Clear-Host + # Set MKVMerge.exe Path $MKVMerge = "`"H:\z_MKV\mkvtoolnix\mkvmerge.exe`"" +# For the parameters to pass to MKVMerge executable, will be construct #Set Source and Target directories (Don't put an \ at the end) $sourceDirectory_1 = "PATH_TO_SOURCE_1" @@ -33,14 +36,19 @@ $sourceDirectory_2 = "PATH_TO_SOURCE_2" $destinationDirectory = "PATH_TO_DESTINATION" # Rename output file with this settings : -$chain_to_search = '(.*).S(\d*)E(\d*).(.*)H264(.*)' -#$chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).720p.(.*)x264(.*)' -$chain__to_replace = '$1 (2003) - S$2E$3 - $4x265-10bits$5--Reencoded' +# $chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).(.*)H264(.*)' +$chain_to_search = '(\w+)\.S(\d{2})E(\d{2})(.*)1080p.(.*)H.264(.*)' +# $chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded' +$chain__to_replace = '$1 (2021) - S$2E$3 - 1080p.$5x265-10bits$6--Reencoded' # The filenames must be like : blabla.S00E00.blabla.H.264.blabla # They will be renamed to : blabla - S00E00 - blabla.x265-10bits.blabla--Reencoded # If you don't want the rename to be made, juste set to '' the variables. +# If there is no internal subtitles to keep : +# Set to $false for no internal subtitle +# Set to $true for one or more internal subtitles +$Internal_SUB = $true # Is there an external subtitle ? Set the number of .SRT (0 - 2) # It's exclusive, no internal SUB will be proceed.. @@ -55,6 +63,11 @@ $SubExtension_2 = 'fre.srt' #If source and destination are the same folder, set this to True, Otherwise let it to "False" $merged_SUFFIX_name = "False" +# Move MKV1 (and SRT) to Not-Merged folder ? Set to $false or $true +$move_mkv1_after_merge = $true +# Move MKV2 (and SRT) to Not-Merged folder ? Set to $false or $true +$move_mkv1_after_merge = $true + # Initialization for those 2 variables, do not change them ! $MKVMerge_sub_param = "" $MKVMerge_audio_param = "" @@ -64,22 +77,22 @@ $MKVMerge_audio_param = "" # ================== AUDIO ================== # Track 1 = Audio n°1 # Name and language of Audio Track n°1 -$AudioTrackName_1 = "`"1:English - DDP 5.1`"" -$AudioLang_1 = "1:en" +$AudioTrackName_1 = "1:English - DDP 5.1" +$AudioLang_1 = "1:fr" $AudioTrack_1_default = "1:yes" -# Define track order +# Define track order. Do not modify it unless you changed the track number in this section $track_order = "1:0,0:1" # $MKVMerge_audio_param = '--language', "$AudioLang_1", '--track-name', "$AudioTrackName_1", '--default-track', "$AudioTrack_1_default" -$MKVMerge_audio_param = "--language $AudioLang_1 --track-name $AudioTrackName_1 --default-track $AudioTrack_1_default" +$MKVMerge_audio_param = "--language $AudioLang_1 --track-name `"$AudioTrackName_1`" --default-track $AudioTrack_1_default" # # Track 2 = Audio n°2 # # Name and language of Audio Track n°2 -# $AudioTrackName_1 = "`"2:English - DDP 5.1`"" +# $AudioTrackName_1 = "2:English - DDP 5.1" # $AudioLang_1 = "2:en" # $AudioTrack_1_default = "2:yes" -# # Define track order +# # Define track order. Do not modify it unless you changed the track number in this section # $track_order = "1:0,0:1,0:2" -# $MKVMerge_audio_param += "--language $AudioLang_2 --track-name $AudioTrackName_2 --default-track $AudioTrack_2_default" +# $MKVMerge_audio_param += "--language $AudioLang_2 --track-name `"$AudioTrackName_2`" --default-track $AudioTrack_2_default" ########################################## #### FILE 2 - MKV - Keeping only the video @@ -115,29 +128,35 @@ if ( $NB_External_SUB -ne 0 ) { } else { # ================== INTERNAL SUBTITLES ================== - # Track 2 = Sub n°1 to keep - # Name and language of Subtitle Track n°1 + Sync Value - $SubTrackName_1 = "`"2:English - SRT`"" - $SubTrackLang_1 = "2:en" - $SubTrack_1_default = "2:yes" - $sub_charset_1 = "2:UTF-8" - # Define track order - $track_order += ",0:2" - $subtitle_tracks = "2" - # $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default" - $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name $SubTrackName_1 --default-track $SubTrack_1_default" + if ( $Internal_SUB -eq $false ) { + # Track 2 = Sub n°1 to keep + # Name and language of Subtitle Track n°1 + Sync Value + # $SubTrackName_1 = "2:English - SRT" + # $SubTrackLang_1 = "2:en" + # $SubTrack_1_default = "2:yes" + # $sub_charset_1 = "2:UTF-8" + # # Define track order + # $track_order += ",0:2" + # $subtitle_tracks = "2" + # # $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default" + # $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name `"$SubTrackName_2`" --default-track $SubTrack_1_default" - # Track 3 = Sub n°2 to keep - # Name and language of Subtitle Track n°1 + Sync Value - # $SubTrackName_1 = "3:English SDH - SRT" - # $SubTrackLang_1 = "3:eng" - # $SubTrack_1_default = "3:yes" - # $sub_charset_1 = "3:UTF-8" - # # Define track order - # $track_order += ",0:3" - # $subtitle_tracks = "3" - # $MKVMerge_sub_param += "--sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name $SubTrackName_2 --default-track $SubTrack_2_default" - #### + # Track 3 = Sub n°2 to keep + # Name and language of Subtitle Track n°1 + Sync Value + $SubTrackName_2 = "3:English SDH - SRT" + $SubTrackLang_2 = "3:eng" + $SubTrack_2_default = "3:yes" + $sub_charset_2 = "3:UTF-8" + # Define track order + $track_order += ",0:3" + $subtitle_tracks = "3" + $MKVMerge_sub_param += "--sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name `"$SubTrackName_2`" --default-track $SubTrack_2_default" + #### + } + else { + # No internal subtitles are to be kept... + $MKVMerge_sub_param = "" + } } ## End of part where there is something to change ! ##============================================================================================== @@ -304,11 +323,9 @@ Foreach ($MKV_1 in $MKV_1_List) { # Set Output File Name If ($merged_SUFFIX_name -eq "True") { $Output = $destinationDirectory + "\" + $VideoTrackName + '___MERGED' + '.mkv' - $Output = "`"$Output`"" } elseif ($merged_SUFFIX_name -eq "False") { # $Output = $destinationDirectory + "\" + $VideoTrackName + '.mkv' $Output = "$destinationDirectory" + "\" + "$VideoTrackName" + ".mkv" - $Output = "`"$Output`"" } else { write-host "Error in the value of the merged_SUFFIX_name variable. Current value = $merged_SUFFIX_name" -ForegroundColor "red" write-host "Should be set to True or False.`nScript is exiting now..." -ForegroundColor "white" @@ -328,7 +345,7 @@ Foreach ($MKV_1 in $MKV_1_List) { $SRT_1_Name = $MKV_1_name + ".$SubExtension_1" $SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name - $MKVMerge_param_start = "---output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --no-video --no-subtitles" + $MKVMerge_param_start = "---output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --no-video --no-subtitles" $MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`"" $MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`"" @@ -350,9 +367,15 @@ Foreach ($MKV_1 in $MKV_1_List) { } else { # INTERNAL SUB to keep - - $MKVMerge_param_start = "--output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video" - $MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`"" + $MKVMerge_param_start = "--output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video" + if ( $Internal_SUB -eq $true ) { + # There is some internal subtitles to keep + $MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`"" + } + else { + # There is no internal subtitles to keep + $MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`"" + } $MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`"" $MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_mkv2" @@ -387,15 +410,18 @@ Foreach ($MKV_1 in $MKV_1_List) { #Remove-Item $Sub #Remove-Item $OtherSub # Move to folder Not-Merged, this folder's existence has already been tested, and the folder is created. - Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose - Move-Item -Path $MKV_2 -Destination $Path_Folder_NotMerged_2 -Verbose - - if ( $NB_External_SUB -ne 0 ) { - Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose - if ( $NB_External_SUB -eq 2 ) { - Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose + if ( $move_mkv1_after_merge -eq $true ) { + Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose + if ( $NB_External_SUB -ne 0 ) { + Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose + if ( $NB_External_SUB -eq 2 ) { + Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose + } } } + if ( $move_mkv2_after_merge -eq $true ) { + Move-Item -Path $MKV_2 -Destination $Path_Folder_NotMerged_2 -Verbose + } } Else { write-host "File NON-EXISTANT - $Output" -foreground "red" From 28eb756ab0508fddad5ecb7859646a3a0553d3e8 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Fri, 5 Nov 2021 22:21:05 +0100 Subject: [PATCH 3/8] Correction d'une petite erreur sur un test conditionnel... --- ...h Merge one MKV Audio with another video MKV.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 index a0ab6bb..918ea77 100644 --- a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 +++ b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 @@ -36,8 +36,10 @@ $sourceDirectory_2 = "PATH_TO_SOURCE_2" $destinationDirectory = "PATH_TO_DESTINATION" # Rename output file with this settings : +# $chain_to_search = '' # $chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).(.*)H264(.*)' $chain_to_search = '(\w+)\.S(\d{2})E(\d{2})(.*)1080p.(.*)H.264(.*)' +# $chain__to_replace = '' # $chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded' $chain__to_replace = '$1 (2021) - S$2E$3 - 1080p.$5x265-10bits$6--Reencoded' @@ -57,7 +59,7 @@ $NB_External_SUB = 0 # Extension without the . $MkvExtension = "mkv" #Set Subtitle Extension (Don't add the . before the extension) -$SubExtension_1 = 'srt' +$SubExtension_1 = 'eng.srt' $SubExtension_2 = 'fre.srt' #If source and destination are the same folder, set this to True, Otherwise let it to "False" @@ -68,9 +70,10 @@ $move_mkv1_after_merge = $true # Move MKV2 (and SRT) to Not-Merged folder ? Set to $false or $true $move_mkv1_after_merge = $true -# Initialization for those 2 variables, do not change them ! +# Initialization for those 3 variables, do not change them ! $MKVMerge_sub_param = "" $MKVMerge_audio_param = "" +$subtitle_tracks = "" # ################## #### FILE 1 - Keeping all but the video @@ -78,7 +81,7 @@ $MKVMerge_audio_param = "" # Track 1 = Audio n°1 # Name and language of Audio Track n°1 $AudioTrackName_1 = "1:English - DDP 5.1" -$AudioLang_1 = "1:fr" +$AudioLang_1 = "1:eng" $AudioTrack_1_default = "1:yes" # Define track order. Do not modify it unless you changed the track number in this section $track_order = "1:0,0:1" @@ -128,7 +131,7 @@ if ( $NB_External_SUB -ne 0 ) { } else { # ================== INTERNAL SUBTITLES ================== - if ( $Internal_SUB -eq $false ) { + if ( $Internal_SUB -eq $true ) { # Track 2 = Sub n°1 to keep # Name and language of Subtitle Track n°1 + Sync Value # $SubTrackName_1 = "2:English - SRT" @@ -367,7 +370,7 @@ Foreach ($MKV_1 in $MKV_1_List) { } else { # INTERNAL SUB to keep - $MKVMerge_param_start = "--output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video" + $MKVMerge_param_start = "--output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video" if ( $Internal_SUB -eq $true ) { # There is some internal subtitles to keep $MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`"" From ea380d551c6fe11e96c91b728149ae4f86e117f0 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Mon, 8 Nov 2021 13:13:19 +0100 Subject: [PATCH 4/8] =?UTF-8?q?Correctif=20sur=20la=20chaine=20ExtSubTrack?= =?UTF-8?q?Name=5F=20:=20les=20"=20"=20forc=C3=A9es=20ne=20sont=20plus=20i?= =?UTF-8?q?ndispensables=20car=20mis=20ailleurs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Batch Merge one MKV Audio with another video MKV.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 index 918ea77..7ba980d 100644 --- a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 +++ b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 @@ -109,7 +109,7 @@ if ( $NB_External_SUB -ne 0 ) { # ================== SUBTITLES ================== # Track 0 = Sub n°1 to keep # Name and language of Subtitle Track n°0 + Sync Value - $ExtSubTrackName_1 = "`"0:English - SRT`"" + $ExtSubTrackName_1 = "0:English - SRT" $ExtSubTrackLang_1 = "0:eng" $ExtSubTrack_1_default = "0:yes" $ExtSub_charset_1 = "0:UTF-8" @@ -120,7 +120,7 @@ if ( $NB_External_SUB -ne 0 ) { # ================== SUBTITLES ================== # Track 0 = Sub n°1 to keep # Name and language of Subtitle Track n°0 + Sync Value - $ExtSubTrackName_2 = "`"0:Français - SRT`"" + $ExtSubTrackName_2 = "0:Français - SRT" $ExtSubTrackLang_2 = "0:fr" $ExtSubTrack_2_default = "0:no" $ExtSub_charset_2 = "0:UTF-8" From 2412b203ed239f0df88538459c35a3c6884db85c Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Tue, 9 Nov 2021 23:22:44 +0100 Subject: [PATCH 5/8] Fix : faute de frappe... --- .../Batch Merge one MKV Audio with another video MKV.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 index 7ba980d..856d82e 100644 --- a/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 +++ b/Scripts-Divers/Batch Merge one MKV Audio with another video MKV.ps1 @@ -142,7 +142,7 @@ else { # $track_order += ",0:2" # $subtitle_tracks = "2" # # $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default" - # $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name `"$SubTrackName_2`" --default-track $SubTrack_1_default" + # $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name `"$SubTrackName_1`" --default-track $SubTrack_1_default" # Track 3 = Sub n°2 to keep # Name and language of Subtitle Track n°1 + Sync Value From 43f47b8fbfc09a5705a66e7091e60a8c23c4a529 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Tue, 16 Nov 2021 23:15:16 +0100 Subject: [PATCH 6/8] De quoi supprimer des sous-titres d'un MKV et ajouter au max 2 SRT externes --- .../Batch Remove Sub but all selected.ps1 | 332 ++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 Scripts-Divers/Batch Remove Sub but all selected.ps1 diff --git a/Scripts-Divers/Batch Remove Sub but all selected.ps1 b/Scripts-Divers/Batch Remove Sub but all selected.ps1 new file mode 100644 index 0000000..e5814d4 --- /dev/null +++ b/Scripts-Divers/Batch Remove Sub but all selected.ps1 @@ -0,0 +1,332 @@ +# ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +# │ Powershell Script │ +# │ │ +# │ Objective : to keep up to 2 internal subtiles form a MKV and adding 1 or 2 external SRT. │ +# │ │ +# │ Configure : │ +# │ - the Audio_ variables │ +# │ - the ExtSubTrack_ variables │ +# │ - All variables before the function Get-SubID │ +# │ - The Track ID in the function Get-SubID + the filename for those track ID │ +# └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + +Clear-Host + +# Set MKVMerge.exe Path +$MKVMerge = "`"H:\z_MKV\mkvtoolnix\mkvmerge.exe`"" +# For the parameters to pass to MKVMerge executable, will be construct + +$sourceDirectory_1 = "PATH_TO_SOURCE_1" +$destinationDirectory = "PATH_TO_DESTINATION" + +# Remove dots before the season or the resolution ? +$remove_dots = $true +# If there is the year in the title, set it to $true +$set_year_with_brackets = $false +# $chain_to_search = '' +# $chain__to_replace = '' +$chain_to_search = '(.*) S(\d{2})E(\d{2}).(.*)' +$chain__to_replace = '$1 - S$2E$3 - $4--Custom' + +# Move MKV1 (and SRT) to Not-Merged folder ? Set to $false or $true +$move_mkv1_after_merge = $true + +# ================== AUDIO ================== Common for all videos +# Track 1 = Audio n°1 +# Name and language of Audio Track n°1 +$AudioTrackName_1 = "1:Japonais - AAC 2.0" +$AudioLang_1 = "1:ja" # en for english / fr for french / ja for japanese +$AudioTrack_1_default = "1:yes" +# Define track order. Do not modify it unless you changed the track number in this section +$track_order = "0:0,0:1" + +# ================================================================ + +# To keep or not internal subtitles +$keep_internal_Sub = $false +# NOTE : Internal SUB always came first in the track order ! + +# =========================================== +# ================== Internal SUB ? ========= +$Internal_SUB_Number = 2 # Works only if $External_SUB = $true + # Max 2 Internal SRT is configured in the script. + # If set to 2, must be 2 SRT configured +$SubTrackName_1 = "Français - SRT" +$SubTrackLang_1 = "fr" # en for english / fr for french / jp for japanese +$SubTrack_1_default = "yes" +$sub_charset_1 = "UTF-8" + +$SubTrackName_2 = "English SDH - SRT" +$SubTrackLang_2 = "en" # en for english / fr for french / jp for japanese +$SubTrack_2_default = "no" +$sub_charset_2 = "UTF-8" + +# =========================================== + + +# =========================================== +# ================== External SUB ? ========= +# Must have the same name as MKV1 +$External_SUB = $true +$External_SUB_Number = 1 # Works only if $External_SUB = $true + # Max 2 External SRT is configured in the script. + # If set to 2, must be 2 SRT configured +# Set Subtitle Extension (Don't add the . before the extension) +$SubExtension_1 = 'fre.srt' +$SubExtension_2 = 'fre.srt' + +#### FILE 2 - SRT_1 - Keeping all but the video (audio + chapters tags) +# ================== SUBTITLES ================== +# Track 0 = Sub n°1 to keep +# Name and language of Subtitle Track n°0 + Sync Value +$ExtSubTrackName_1 = "0:Français - SRT" +$ExtSubTrackLang_1 = "0:fr" +$ExtSubTrack_1_default = "0:yes" +$ExtSub_charset_1 = "0:UTF-8" + +#### FILE 3 - SRT_2 - Keeping all but the video (audio + chapters tags) +# ================== SUBTITLES ================== +# Track 0 = Sub n°1 to keep +# Name and language of Subtitle Track n°0 + Sync Value +$ExtSubTrackName_2 = "0:Français - SRT" +$ExtSubTrackLang_2 = "0:fr" +$ExtSubTrack_2_default = "0:no" +$ExtSub_charset_2 = "0:UTF-8" + +# Define track order - DO NOT TOUCH +$track_order_EXT_sub = "" +if ( $External_SUB -eq $true ) { + if ( $External_SUB_Number -eq 1 ) { + $track_order_EXT_sub += ",1:0" + if ( $External_SUB_Number -eq 2 ) { + $track_order_EXT_sub += ",2:0" + } + } +} +# =========================================== + +function Get-SubID { # FOR INTERNAL SUB ! + param ( # sub_1_id for 1st sub to keep + $file_name # sub_2_id for 2nd sub to keep + ) + + switch ($file_name) + { + "FILE1" + { + $sub_1_id = "4" + $sub_2_id = "5" + break + } + "FILE2" + { + $sub_1_id = "5" + $sub_2_id = "6" + break + } + #Default state + Default + { + Write-Host "This file is not set in the script : $file_name" -ForegroundColor "red" + Write-Host "End of script..." -ForegroundColor "red" + Exit + } + } + + return $sub_1_id, $sub_2_id +} + +#Process +$MKV_1_List = Get-ChildItem $sourceDirectory_1 -Filter "*.mkv" | ForEach-Object { $_.FullName } | Sort-Object +$Count_1 = $MKV_1_List.count +Write-Host "$Count_1 MKV's to be processed in $sourceDirectory_1." + +# Testing if the Done_Remerged folder already exists : if yes, it will be renamed, else it will be created. +$Path_Folder_NotMerged_1 = $sourceDirectory_1 + "\Done_Remerged" +If(!(test-path $Path_Folder_NotMerged_1)) { + New-Item -ItemType "Directory" -Force -Path $Path_Folder_NotMerged_1 -Verbose +} else { + # Don't know what's the best... TO BE IMPROVED + #Move-Item -Path $Path_Folder_NotMerged_2 -Destination "$sourceDirectory\Not-Merged--backup" -Verbose + #Move-Item -Path $Path_Folder_NotMerged_2 -Destination "$sourceDirectory\Not-Merged--backup" -Verbose +} + + +# ######################### +# Check if there is the same number of .srt files as .mkv files +if ( $External_SUB -eq $true ) { + if ( $External_SUB_Number -ge 1 ) { # If $NB_External_SUB >= 1 (include =1 and =2) + $SRT_1_List = Get-ChildItem $sourceDirectory_1 -Filter "*.$SubExtension_1" | ForEach-Object { $_.FullName } | Sort-Object + $Count_1_SRT = $SRT_1_List.count + Write-Host "$Count_1_SRT SRT's ($SubExtension_1) to be processed in $sourceDirectory_1." + if ($Count_1 -eq $Count_1_SRT) { + Write-Host "There is the same number of MKV and SRT n°1 files ($SubExtension_1) in this folder. Let's continue." + } else { + Write-Host "The number of MKV and SRT n°1 files isn't the same. ABORT..." -foreground "red" + Exit + } + } + + if ( $External_SUB_Number -eq 2 ) { # Only if $External_SUB_Number = 2 + $SRT_2_List = Get-ChildItem $sourceDirectory_1 -Filter "*.$SubExtension_2" | ForEach-Object { $_.FullName } | Sort-Object + $Count_2_SRT = $SRT_2_List.count + Write-Host "$Count_2_SRT SRT's ($SubExtension_2) to be processed in $sourceDirectory_1." + + if ($Count_1 -eq $Count_2_SRT) { + Write-Host "There is the same number of MKV and SRT n°2 files ($SubExtension_2) in this folder. Let's continue." + } else { + Write-Host "The number of MKV and SRT n°2 files ($SubExtension_2) isn't the same. ABORT..." -foreground "red" + Exit + } + } +} +# ######################### + +$compteur = 1 + +Foreach ($MKV_1 in $MKV_1_List) { + + Write-Host "" -ForegroundColor "black" -BackgroundColor "white" + Write-Host "Traitement du fichier n° $compteur / $Count_1..." -ForegroundColor "black" -BackgroundColor "white" + Write-Host "" -ForegroundColor "black" -BackgroundColor "white" + + # Clear variables + $MKVMerge_param_start = "" + $MKVMerge_param_mkv1 = "" + $MKVMerge_param_srt1 = "" + $MKVMerge_param_srt2 = "" + $MKVMerge_param_all = "" + $MKVMerge_sub_param = "" + $SRT_1_Name = "" + $SRT_2_Name = "" + $SRT_1 = "" + $SRT_2 = "" + + $FormatName_1 = (Get-Item $MKV_1).Basename + $MKV_1_name = $FormatName_1.ToString() + + # Title for the video track and for the destination file + $VideoTrackName = $MKV_1_name + if ( $set_year_with_brackets -eq $true ) { + $VideoTrackName = $VideoTrackName -replace '(\d{4}(?=.*S\d{2}E\d{2}))', '($1)' + } + if ( $remove_dots -eq $true ) { + $VideoTrackName = $VideoTrackName -replace '\.(?=.*S\d{2}E\d{2})', ' ' + } + $VideoTrackName = $VideoTrackName -replace $chain_to_search, $chain__to_replace + $VideoTrackName = "$VideoTrackName" + Write-Host "`tThe Video Track Name will be : `r`n`t`t $VideoTrackName" -ForegroundColor "green" + + $Output = "$destinationDirectory" + "\" + "$VideoTrackName" + ".mkv" + + + # DO NOT TOUCH - Common for all files + $MKVMerge_audio_param = "--language $AudioLang_1 --track-name `"$AudioTrackName_1`" --default-track $AudioTrack_1_default" + + if (( $keep_internal_Sub -eq $true ) -and ( $Internal_SUB_Number -ne 0 )) { + + $sub_1_id, $sub_2_id = Get-SubID $MKV_1_name + + # Track 2 = Sub n°1 to keep + # Name and language of Subtitle Track n°1 + Sync Value + $SubTrackName_1 = $sub_1_id + ":$SubTrackName_1" + $SubTrackLang_1 = $sub_1_id + ":$SubTrackLang_1" + $SubTrack_1_default = $sub_1_id + ":$SubTrack_1_default" + $sub_charset_1 = $sub_1_id + ":$sub_charset_1" + # Define track order + $track_order += ",0:" + $sub_1_id + $subtitle_tracks = "$sub_1_id" + $MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name `"$SubTrackName_1`" --default-track $SubTrack_1_default" + + if ( $Internal_SUB_Number -eq 2 ) { + # Track 3 = Sub n°2 to keep + # Name and language of Subtitle Track n°1 + Sync Value + $SubTrackName_2 = $sub_2_id + ":$SubTrackName_2" + $SubTrackLang_2 = $sub_2_id + ":$SubTrackLang_2" + $SubTrack_2_default = $sub_2_id + ":$SubTrack_2_default" + $sub_charset_2 = $sub_2_id + ":$sub_charset_2" + # Define track order + $track_order += ",0:" + $sub_2_id + $subtitle_tracks += ",$sub_2_id" + $MKVMerge_sub_param += " --sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name `"$SubTrackName_2`" --default-track $SubTrack_2_default" + } + } + elseif (( $keep_internal_Sub -eq $true ) -and ( $Internal_SUB_Number -eq 0 )) { + write-host "Problem with `$keep_internal_Sub=$keep_internal_Sub and `$Internal_SUB_Number=$Internal_SUB_Number.`nIf `$keep_internal_Sub=true, `$Internal_SUB_Number should have a value different from 0 !" -ForegroundColor "Red" + exit + } + + if ( ( $External_SUB_Number -ne 0 ) -and ( $External_SUB -eq $true ) ) { + + # First external SRT to include + $SRT_1_Name = $MKV_1_name + ".$SubExtension_1" + $SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name + + $track_order += $track_order_EXT_sub + + $MKVMerge_param_srt1 = "--sub-charset $Extsub_charset_1 --language $ExtSubTrackLang_1 --track-name `"$ExtSubTrackName_1`" --default-track $ExtSubTrack_1_default `"$SRT_1`"" + $MKVMerge_param_srt_all = "$MKVMerge_param_srt1" + if ( $External_SUB_Number -eq 2 ) { + # Second external SRT to include + $SRT_2_Name = $MKV_1_name + ".$SubExtension_2" + $SRT_2 = $sourceDirectory_1 + "\" + $SRT_2_name + + $MKVMerge_param_srt2 = "--sub-charset $Extsub_charset_2 --language $ExtSubTrackLang_2 --track-name `"$ExtSubTrackName_2`" --default-track $ExtSubTrack_2_default `"$SRT_2`"" + $MKVMerge_param_srt_all += " $MKVMerge_param_srt2" + } + + if ( $keep_internal_Sub -eq $false ) { + $MKVMerge_param_start = "--output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --no-subtitles --track-name `"0:$VideoTrackName`" --default-track 0:yes" + $MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`"" + $MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_srt_all" + } + else { + $MKVMerge_param_start = "--output `"$Output`" --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --track-name `"0:$VideoTrackName`" --default-track 0:yes" + $MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`"" + $MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_srt_all" + } + } + elseif (( $External_SUB_Number -eq 0 ) -and ( $External_SUB -eq $true )) { + write-host "Problem with `$External_SUB_Number=$External_SUB_Number and `$External_SUB=$External_SUB.`nIf `$External_SUB=true, `$External_SUB_Number should have a value different from 0 !" -ForegroundColor "Red" + exit + } + + # To modify a SubTrackName after previous operation... : + # if ( $MKV_1_name -eq "BLABLA" ) { + # $SubTrackName_2 = $sub_2_id + ":Français Québécois - SRT" + # } + + # Write-Host "`$MKVMerge_param_start = $MKVMerge_param_start" -ForegroundColor "White" + # Write-Host "`$MKVMerge_param_mkv1 = $MKVMerge_param_mkv1" -ForegroundColor "White" + # Write-Host "`$MKVMerge_param_all = $MKVMerge_param_all" -ForegroundColor "White" + + # Last step to command construction + $command = "& $MKVMerge $MKVMerge_param_all" + # Launch begin... + Invoke-Expression $command + + Write-Host "" -ForegroundColor "black" -BackgroundColor "white" + Write-Host "Fin du traitement du fichier n° $compteur / $Count_1." -ForegroundColor "black" -BackgroundColor "white" + Write-Host "" -ForegroundColor "black" -BackgroundColor "white" + + If (-Not (Test-Path $Output) ) { + write-host "File NON-EXISTANT - $Output" -foreground "red" + "File NON-EXISTANT - $Output" | Out-File "$destinationDirectory\Errors.txt" -Append + } + else { + if ( $move_mkv1_after_merge -eq $true ) { + Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose + if ( $NB_External_SUB -ne 0 ) { + Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose + if ( $NB_External_SUB -eq 2 ) { + Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose + } + } + } + } + + $compteur++ + + +} \ No newline at end of file From 9f459ad8fe5c716446afd4fda7f6f67513e08266 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Wed, 17 Nov 2021 09:05:54 +0100 Subject: [PATCH 7/8] =?UTF-8?q?Modification=20de=20l'application=20des=20t?= =?UTF-8?q?h=C3=A8mes=20:=20c'est=20d=C3=A9sormais=20plus=20simple.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose/gitea/Changer-Theme-Gitea.md | 174 ++++++++++-------- .../data--gitea/templates/custom/header.tmpl | 26 ++- 2 files changed, 112 insertions(+), 88 deletions(-) diff --git a/docker-compose/gitea/Changer-Theme-Gitea.md b/docker-compose/gitea/Changer-Theme-Gitea.md index 0dc9922..a087438 100644 --- a/docker-compose/gitea/Changer-Theme-Gitea.md +++ b/docker-compose/gitea/Changer-Theme-Gitea.md @@ -30,11 +30,11 @@ Changer le thème de Gitea --- --- -# 1. Ajouter les différents thèmes en laissant le choix à l'utilisateur +# 2. Ajouter les différents thèmes en laissant le choix à l'utilisateur > :memo: Cette partie devrait être compatible avec d'autres thèmes qui n'apportent qu'un seul fichier `.css`. ***À confirmer...*** -## 1.1. Création des dossiers dans `/volume1/docker/gitea/data/` +## 2.1. Création des dossiers dans `/volume1/docker/gitea/data/` - Il faut vérifier si la variable GITEA_CUSTOM a été paramétrée. En temps normal, ce n'est pas le cas. @@ -53,13 +53,99 @@ Changer le thème de Gitea - `templates` - `templates/custom` -## 1.2. Télécharger les différents css +## 1.2. Création du fichier `header.tmpl` -- MAJ v3.0 + +- Créer le fichier `header.tmpl` et l'enregistrer dans le dossier `.../templates/custom/` créé précédemment. +```go +{{ if .IsSigned }} + {{ if and (ne .SignedUser.Theme "gitea") (ne .SignedUser.Theme "arc-green") }} + + + + + + + {{end}} + {{end}} +{{ else if and (ne DefaultTheme "gitea") (ne DefaultTheme "arc-green") }} + + + + + +{{end}} +``` +- Vous pouvez aussi récupérer le fichier tout prêt [dans dossier `data--gitea/public/template/custom/` de ce dépôt](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/src/branch/master/docker-compose/gitea/data--gitea/templates/custom/header.tmpl). Il contient en commentaires quelques détails. + +## 1.3. Modification du fichier `/data/gitea/conf/app.ini` + +### 1.3.1. Point info sur la modification de ce fichier + +Pour modifier ce fichier, il se peut que vous n'ayez pas les permissions d'enregistrer les modifications apportées... Il faudra alors le copier ailleurs, faire les modifications et sauvegarder, puis re-copier dans l'autre sens le fichier dans son dossier d'origine. + +C'est ce que je dois faire. Depuis une ligne de commande SSH, je fais : +- Je copie le fichier dans un dossier où mon utilisateur Admin à les droits en écriture (je ne me logue pas avec l'utilisateur choisir pour Gitea) :
`cp /volume1/docker/gitea/data/gitea/conf/app.ini /volume1/docker/gitea/` +- Je modifie et sauvegarde mon fichier... +- puis je copie en retour le fichier modifier : `cp /volume1/docker/gitea/app.ini /volume1/docker/gitea/data/gitea/conf/` +- Il faut ensuite relancer le conteneur Gitea avec Portainer/DSM ou en CLI : `docker restart gitea` + +### 1.3.2. Ce qu'il faut ajouter au fichier `/data/gitea/conf/app.ini` + +Il faut ajouter ceci au fichier `app.ini` : + +```ini +[ui] +THEMES = gitea,arc-green,dracula,dracula-test,plex,dark,aquamarine,hotline,hotpink,nord,organizr,overseerr,space-gray,onedark,blackberry-abyss,blackberry-amethyst,blackberry-carol,blackberry-dreamscape,blackberry-flamingo,blackberry-hearth,blackberry-martian,blackberry-pumpkin,blackberry-royal,blackberry-shadow,blackberry-solar,blackberry-vanta +DEFAULT_THEME = dracula +``` +> :memo: Note 1 : Il se peut que la section `[ui]` soit déjà présente dans votre `app.ini`, il faudra alors modifier la ligne `THEMES`. +> :memo: Note 2 : **Le thème par défaut n'a plus besoin d'être obligatoirement "gitea".** + +### 2.4.3. Redémarrer le conteneur + +Il faut bien penser à redémarrer le conteneur une fois le app.ini modifié et copié dans `/data/gitea/conf/`. + +## 2.5. Choisir son thème dans l'interface graphique de Gitea + +![](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/raw/branch/master/docker-compose/gitea/tuto-1.png) + +![](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/raw/branch/master/docker-compose/gitea/tuto-2.png) + +![](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/raw/branch/master/docker-compose/gitea/tuto-3.png) + + + + +# 2. Méthode précédente - Ajouter les différents thèmes en laissant le choix à l'utilisateur + +> :memo: Cette partie devrait être compatible avec d'autres thèmes qui n'apportent qu'un seul fichier `.css`. ***À confirmer...*** + +## 2.1. Création des dossiers dans `/volume1/docker/gitea/data/` + +- Il faut vérifier si la variable GITEA_CUSTOM a été paramétrée. En temps normal, ce n'est pas le cas. + +- Si ce n'est pas le cas, on peut aller vérifier le chemin qui est paramétré pour le dossier dit CUSTOM de gitea. Pour celà, il faut aller ici : +`https://url-de-votre-gitea.tlds/admin/config` + +- Puis chercher la ligne `GITEA_CUSTOM` où apparaîtra le chemin d'accès : `/data/gitea`. + +- Dans le cas d'une installation Docker, ça donnerait ceci : `/docker/gitea/data/gitea` +
(voir le fichier **docker-compose.yml** pour le chemin d'accès avant le `/data/gitea`) + +- Il faudra alors créer les dossiers suivants : + + - `public` + - `public/css` + - `templates` + - `templates/custom` + +## 2.2. Télécharger les différents css - Télécharger les différents fichiers .css [du dossier `data--gitea/public/css/` de ce dépôt](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/src/branch/master/docker-compose/gitea/data--gitea/public/css). *(Ne pas les renommer.)* - Placer ces fichiers dans le dossier `...public/css` créé précédemment. -## 1.3. Création du fichier `header.tmpl` -- MAJ v2.1 +## 2.3. Création du fichier `header.tmpl` -- MAJ v2.1 - Créer le fichier `header.tmpl` et l'enregistrer dans le dossier `.../templates/custom/` créé précédemment. ```html @@ -73,9 +159,9 @@ Changer le thème de Gitea ``` - Vous pouvez aussi récupérer le fichier tout prêt [dans dossier `data--gitea/public/template/custom/` de ce dépôt](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/src/branch/master/docker-compose/gitea/data--gitea/templates/custom/header.tmpl). Il contient en commentaires quelques détails. -## 1.4. Modification du fichier `/data/gitea/conf/app.ini` +## 2.4. Modification du fichier `/data/gitea/conf/app.ini` -### 1.4.1. Point info sur la modification de ce fichier +### 2.4.1. Point info sur la modification de ce fichier Pour modifier ce fichier, il se peut que vous n'ayez pas les permissions d'enregistrer les modifications apportées... Il faudra alors le copier ailleurs, faire les modifications et sauvegarder, puis re-copier dans l'autre sens le fichier dans son dossier d'origine. @@ -85,7 +171,7 @@ C'est ce que je dois faire. Depuis une ligne de commande SSH, je fais : - puis je copie en retour le fichier modifier : `cp /volume1/docker/gitea/app.ini /volume1/docker/gitea/data/gitea/conf/` - Il faut ensuite relancer le conteneur Gitea avec Portainer/DSM ou en CLI : `docker restart gitea` -### 1.4.2. Ce qu'il faut ajouter au fichier `/data/gitea/conf/app.ini` +### 2.4.2. Ce qu'il faut ajouter au fichier `/data/gitea/conf/app.ini` Il faut ajouter ceci au fichier `app.ini` : @@ -97,11 +183,11 @@ DEFAULT_THEME = gitea > :memo: Note 1 : Il se peut que la section `[ui]` soit déjà présente dans votre `app.ini`, il faudra alors modifier la ligne `THEMES`. > :memo: Note 2 : **Il faut que le thème par défaut soit "gitea" car les nouveaux thèmes de theme.park se base sur celui-là.** -### 1.4.3. Redémarrer le conteneur +### 2.4.3. Redémarrer le conteneur Il faut bien penser à redémarrer le conteneur une fois le app.ini modifié et copié dans `/data/gitea/conf/`. -## 1.5. Choisir son thème dans l'interface graphique de Gitea +## 2.5. Choisir son thème dans l'interface graphique de Gitea ![](https://gitea.zoz-serv.org/Zoz/plex_fr_discord_repo/raw/branch/master/docker-compose/gitea/tuto-1.png) @@ -114,72 +200,4 @@ Il faut bien penser à redémarrer le conteneur une fois le app.ini modifié et Voilà, c'est la fin :D ---- ---- -La méthode ci-dessous est une méthode que je ne conseille pas, car il n'est pas possible de laisser l'utilisateur choisir son style, et changer est plus pénible... bien que ce soit la méthode indiquée actuellement par l'auteur des thèmes... - -# 2. Autre méthode (déconseillée et dépréciée) : Modifier le thème sans laisser le choix à l'utilisateur - -## 2.1. Installer le thème - -Il faut vérifier si la variable GITEA_CUSTOM a été paramétrée. En temps normal, ce n'est pas le cas. - -Si ce n'est pas le cas, on peut aller vérifier le chemin qui est paramétré pour le dossier dit CUSTOM de gitea. Pour celà, il faut aller ici :
-`https://url-de-votre-gitea.tld/admin/config` - -Puis chercher la ligne `GITEA_CUSTOM` où apparaîtra le chemin d'accès : `/data/gitea`. - -Dans le cas d'une installation Docker, ça donnerait ceci : `/docker/gitea/data/gitea` -
(voir le fichier **docker-compose.yml** pour le chemin d'accès avant le `/data/gitea`) - -Il faudra alors créer les dossiers suivants : - -- `public` -- `templates` -- `templates/custom` - -Puis il faudra suivre les instructions du thème choisi. Pour ceux qui n'auraient pas d'instructions, le fichier `styles.css` devra se trouver dans le dossier `public`. - -## 2.2. Exemple avec le dernier lien du dépôt donnée précédemment - -### 2.2.1. Installer le thème (imposé pour tous) - -Je vais prendre le dernier lien présent dans le dépôt donné avant la table des matières. - -> - [theme.park](https://docs.theme-park.dev/themes/gitea/) - A theme suite for Gitea. - -Dans ce nouveau dépôt ( https://docs.theme-park.dev/themes/gitea/ ) vous trouverez plusieurs thèmes. - -Je trouve les thèmes plex, dark et space-gray relativement sympas. -Des captures sont présentes plus bas dans la page : https://docs.theme-park.dev/themes/gitea/#screenshots - -Il faut créer deux fichiers : - -- `public/styles.css` qui contient (avec des commentaires perso) : -```css -/* Source : https://docs.theme-park.dev/themes/gitea/ - Possibilités : https://theme-park.dev/CSS/themes/gitea/XXX.css - aquamarine.css <--- pas terrible - hotline.css - plex.css <--- TOP - dark.css <--- TOP - space-gray.css <--- TOP - organizr-dark.css - dracula.css -*/ -@import url("https://theme-park.dev/CSS/themes/gitea/plex.css"); -``` - -- `templates/custom/header.tmpl` qui contient : -```html - -``` -Une fois les fichiers créés et placés dans ces dossiers (faire attention aux permissions), il suffit de redémarrer Gitea (ou le conteneur si installation en Docker). - -### 2.2.2. Changer le thème - -Pour changer le thème, il suffit de : - -- modifier le `public/styles.css` avec le nom du css désiré ; -- redémarrer Gitea ; -- ne pas oublier de vider le cache du navigateur... sinon le nouveau thème ne sera pas visible... (ça m'a pris 15 minutes d'essais et au bout de ce temps l'utilisation d'un autre navigateur pour le comprendre...). +--- \ No newline at end of file diff --git a/docker-compose/gitea/data--gitea/templates/custom/header.tmpl b/docker-compose/gitea/data--gitea/templates/custom/header.tmpl index f8b3e2c..06e8f4d 100644 --- a/docker-compose/gitea/data--gitea/templates/custom/header.tmpl +++ b/docker-compose/gitea/data--gitea/templates/custom/header.tmpl @@ -1,11 +1,17 @@ - -{{if .IsSigned }} - {{ if ne .SignedUser.Theme "gitea" }} - - {{end}} -{{else if ne DefaultTheme "gitea"}} - +{{ if .IsSigned }} + {{ if and (ne .SignedUser.Theme "gitea") (ne .SignedUser.Theme "arc-green") }} + + + + + + + {{end}} + {{end}} +{{ else if and (ne DefaultTheme "gitea") (ne DefaultTheme "arc-green") }} + + + + + {{end}} \ No newline at end of file From ef31ea82bea3a33596127e3f949ad2e6ecfcb7e8 Mon Sep 17 00:00:00 2001 From: MilesTEG Date: Wed, 17 Nov 2021 17:10:45 +0100 Subject: [PATCH 8/8] MAJ du tuto :) --- docker-compose/gitea/Changer-Theme-Gitea.md | 33 +++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/docker-compose/gitea/Changer-Theme-Gitea.md b/docker-compose/gitea/Changer-Theme-Gitea.md index a087438..4393b0f 100644 --- a/docker-compose/gitea/Changer-Theme-Gitea.md +++ b/docker-compose/gitea/Changer-Theme-Gitea.md @@ -1,6 +1,7 @@ Changer le thème de Gitea ============ --- +> :pencil2: **Mise à jour v3.0 :** Gros changement header.tmpl suite à la MAJ par theme-park. Suppression de l'ancienne méthode.
> :pencil2: **Mise à jour v2.1 :** Petit changement du header.tmpl suite à la MAJ 1.15 de Gitea.
> :pencil2: **Mise à jour :** De nouveaux thèmes sont disponibles. Il faut re-télécharger les fichiers CSS.
*Voir* [§ 1. Ajouter les différents thèmes en laissant le choix à l'utilisateur](#1-ajouter-les-différents-thèmes-en-laissant-le-choix-à-lutilisateur) @@ -13,28 +14,30 @@ Changer le thème de Gitea ## Table des matières - [1. Ajouter les différents thèmes en laissant le choix à l'utilisateur](#1-ajouter-les-différents-thèmes-en-laissant-le-choix-à-l-utilisateur) - [1.1. Création des dossiers dans `/volume1/docker/gitea/data/`](#1-1-création-des-dossiers-dans-volume1-docker-gitea-data) - - [1.2. Télécharger les différents css](#1-2-télécharger-les-différents-css) - - [1.3. Création du fichier `header.tmpl` -- MAJ v2.1](#1-3-création-du-fichier-header-tmpl-maj-v2-1) - - [1.4. Modification du fichier `/data/gitea/conf/app.ini`](#1-4-modification-du-fichier-data-gitea-conf-app-ini) - - [1.4.1. Point info sur la modification de ce fichier](#1-4-1-point-info-sur-la-modification-de-ce-fichier) - - [1.4.2. Ce qu'il faut ajouter au fichier `/data/gitea/conf/app.ini`](#1-4-2-ce-qu-il-faut-ajouter-au-fichier-data-gitea-conf-app-ini) - - [1.4.3. Redémarrer le conteneur](#1-4-3-redémarrer-le-conteneur) - - [1.5. Choisir son thème dans l'interface graphique de Gitea](#1-5-choisir-son-thème-dans-l-interface-graphique-de-gitea) -- [2. Autre méthode (déconseillée et dépréciée) : Modifier le thème sans laisser le choix à l'utilisateur](#2-autre-méthode-déconseillée-et-dépréciée-modifier-le-thème-sans-laisser-le-choix-à-l-utilisateur) - - [2.1. Installer le thème](#2-1-installer-le-thème) - - [2.2. Exemple avec le dernier lien du dépôt donnée précédemment](#2-2-exemple-avec-le-dernier-lien-du-dépôt-donnée-précédemment) - - [2.2.1. Installer le thème (imposé pour tous)](#2-2-1-installer-le-thème-imposé-pour-tous) - - [2.2.2. Changer le thème](#2-2-2-changer-le-thème) + - [1.2. Création du fichier `header.tmpl` -- MAJ v3.0](#1-2-création-du-fichier-header-tmpl-maj-v3-0) + - [1.3. Modification du fichier `/data/gitea/conf/app.ini`](#1-3-modification-du-fichier-data-gitea-conf-app-ini) + - [1.3.1. Point info sur la modification de ce fichier](#1-3-1-point-info-sur-la-modification-de-ce-fichier) + - [1.3.2. Ce qu'il faut ajouter au fichier `/data/gitea/conf/app.ini`](#1-3-2-ce-qu-il-faut-ajouter-au-fichier-data-gitea-conf-app-ini) + - [2.4.3. Redémarrer le conteneur](#2-4-3-redémarrer-le-conteneur) + - [2.5. Choisir son thème dans l'interface graphique de Gitea](#2-5-choisir-son-thème-dans-l-interface-graphique-de-gitea) +- [2. Méthode précédente - Ajouter les différents thèmes en laissant le choix à l'utilisateur](#2-méthode-précédente-ajouter-les-différents-thèmes-en-laissant-le-choix-à-l-utilisateur) + - [2.1. Création des dossiers dans `/volume1/docker/gitea/data/`](#2-1-création-des-dossiers-dans-volume1-docker-gitea-data) + - [2.2. Télécharger les différents css](#2-2-télécharger-les-différents-css) + - [2.3. Création du fichier `header.tmpl` -- MAJ v2.1](#2-3-création-du-fichier-header-tmpl-maj-v2-1) + - [2.4. Modification du fichier `/data/gitea/conf/app.ini`](#2-4-modification-du-fichier-data-gitea-conf-app-ini) + - [2.4.1. Point info sur la modification de ce fichier](#2-4-1-point-info-sur-la-modification-de-ce-fichier) + - [2.4.2. Ce qu'il faut ajouter au fichier `/data/gitea/conf/app.ini`](#2-4-2-ce-qu-il-faut-ajouter-au-fichier-data-gitea-conf-app-ini) + - [2.4.3. Redémarrer le conteneur](#2-4-3-redémarrer-le-conteneur-1) + - [2.5. Choisir son thème dans l'interface graphique de Gitea](#2-5-choisir-son-thème-dans-l-interface-graphique-de-gitea-1) ---- --- -# 2. Ajouter les différents thèmes en laissant le choix à l'utilisateur +# 1. Ajouter les différents thèmes en laissant le choix à l'utilisateur > :memo: Cette partie devrait être compatible avec d'autres thèmes qui n'apportent qu'un seul fichier `.css`. ***À confirmer...*** -## 2.1. Création des dossiers dans `/volume1/docker/gitea/data/` +## 1.1. Création des dossiers dans `/volume1/docker/gitea/data/` - Il faut vérifier si la variable GITEA_CUSTOM a été paramétrée. En temps normal, ce n'est pas le cas.