RadioTagger.psm1
|
#Requires -Modules ID3 # --- texts $text_prompt_whichshow = "C'est quoi ton émission?" $text_prompt_whichepisode = "Quel épisode?" $text_prompt_showtitle = "Quel est le titre de l'émission?" $text_prompt_showdate = "Quelle est la date de l'émission?" $text_prompt_extract_title_or_skip = "Quel est le titre de l'extrait? ('i' pour ignorer ce fichier)" $text_try_again_or_exit = "Try again! (taper 'exit' pour quitter)" $text_checking_prerequisite = "Vérification des fichiers requis..." $text_renaming_files = "Renommage des fichiers..." $text_tagging_files = "Taguage des fichiers..." $text_tagging_additional_files = "Taguage de fichiers additionnels..." $text_tagging_one_file = "Taguage de :" $text_error_failed_miserably = "Pikez Super Show Taguer a super bugué" $text_error_directory_notfound = "pas de répertoire" $text_error_file_notfound = "pas de fichier" $text_error_cannot_continue = "PSST ne peut pas continuer" $text_debug_currentdir = "répertoire courant" # --- vars $classical_name_ecolevolante = "L'École Volante" $alternative_names_ecolevolante = $classical_name_ecolevolante, "ev", "ecole volante", "evolante" $directory_ecolevolante = "L'Ecole Volante" $classical_name_midinale = "La Midinale" $alternative_names_midinale = $classical_name_midinale, "mi", "midi", "midinale" $directory_midinale = "La Midinale" $classical_name_dcdcdc = "Du cul, du cul, du cul" $alternative_names_dcdcdc = $classical_name_dcdcdc, "dc", "dcdcdc" $directory_dcdcdc = "du cul, du cul, du cul" # --- functions # - function : enter and splash function enter_splash() { "- --- --- --- --- --- --- -" "- Pikez Super Show Tagger -" "- (v00.01) -" "- --- --- --- --- --- --- -" } # - function : exit after internal failure function exit_miserably() { "ERROR : $text_error_failed_miserably" "- --- --- --- --- --- --- -" } # - function : exit gloriously function exit_ok() { "- --- --- --- --- --- --- -" "- Pikez Super Show Tagger -" "- ( done ) -" "- --- --- --- --- --- --- -" } # - function : tag files for 'L'École Volante' function tag_ecole_volante() { $exit = $false do { $ep = Read-Host -Prompt $text_prompt_whichepisode if ( $ep.Equals("exit") ) { $exit = $true } else { if ( !@($(ls -Directory).Name).Contains($ep) ) { $text_try_again_or_exit ; $ep = "notfound" } else { pushd -StackName stack_psst $ep $text_checking_prerequisite $validated = $true "0.mp3", "1.mp3", "2.mp3", "3.mp3" | foreach { if ( !(Test-Path $_) ) { "$text_error_file_notfound : '$_'" ; $validated = $false } } if ( !$validated ) { $text_error_cannot_continue return } $text_renaming_files "0.mp3 --> podcast_lecole_volante_$ep`.mp3" Rename-Item "0.mp3" "podcast_lecole_volante_$ep`.mp3" "1.mp3 --> podcast_lecole_volante_$ep`_partie1.mp3" Rename-Item "1.mp3" "podcast_lecole_volante_$ep`_partie1.mp3" "2.mp3 --> podcast_lecole_volante_$ep`_partie2.mp3" Rename-Item "2.mp3" "podcast_lecole_volante_$ep`_partie2.mp3" "3.mp3 --> podcast_lecole_volante_$ep`_partie3.mp3" Rename-Item "3.mp3" "podcast_lecole_volante_$ep`_partie3.mp3" $text_tagging_files $show_title = Read-Host -Prompt $text_prompt_showtitle "$text_tagging_one_file podcast_lecole_volante_$ep`.mp3" Set-Id3Tag "podcast_lecole_volante_$ep`.mp3" -Tags @{"Title"="L'École Volante $ep : $show_title (complet)";"Artists"="Association Pikez!";"Album"="L'École Volante";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} "$text_tagging_one_file podcast_lecole_volante_$ep`_partie1.mp3" Set-Id3Tag "podcast_lecole_volante_$ep`_partie1.mp3" -Tags @{"Title"="L'École Volante $ep : $show_title (partie 1)";"Artists"="Association Pikez!";"Album"="L'École Volante";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} "$text_tagging_one_file podcast_lecole_volante_$ep`_partie2.mp3" Set-Id3Tag "podcast_lecole_volante_$ep`_partie2.mp3" -Tags @{"Title"="L'École Volante $ep : $show_title (partie 2)";"Artists"="Association Pikez!";"Album"="L'École Volante";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} "$text_tagging_one_file podcast_lecole_volante_$ep`_partie3.mp3" Set-Id3Tag "podcast_lecole_volante_$ep`_partie3.mp3" -Tags @{"Title"="L'École Volante $ep : $show_title (partie 3)";"Artists"="Association Pikez!";"Album"="L'École Volante";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} $text_tagging_additional_files $additional_files = $(Get-ChildItem .\* -Filter "*.mp3" -Exclude "podcast_lecole_volante_$ep`.mp3", "podcast_lecole_volante_$ep`_partie1.mp3", "podcast_lecole_volante_$ep`_partie2.mp3", "podcast_lecole_volante_$ep`_partie3.mp3").Name $additional_files | foreach { $file = $_ $extract_title = Read-Host -Prompt "($_) $text_prompt_extract_title_or_skip" if ( !$extract_title.Equals("i") ) { "$text_tagging_one_file $file" Set-Id3Tag $file -Tags @{"Title"="L'École Volante $ep : $show_title ($extract_title)";"Artists"="Association Pikez!";"Album"="L'École Volante";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} } } popd -StackName stack_psst } } } while ( $ep.Equals("notfound") -and !$exit ) } # - function : tag files for 'La Midinale' function tag_midinale() { $exit = $false do { $ep = Read-Host -Prompt $text_prompt_whichepisode if ( $ep.Equals("exit") ) { $exit = $true } else { if ( !@($(ls -Directory).Name).Contains("La Midinale $ep") ) { $text_try_again_or_exit ; $ep = "notfound" } else { pushd -StackName stack_psst "La Midinale $ep" $text_checking_prerequisite $validated = $true "0.mp3", "1.mp3", "2.mp3", "3.mp3" | foreach { if ( !(Test-Path $_) ) { "$text_error_file_notfound : '$_'" ; $validated = $false } } if ( !$validated ) { $text_error_cannot_continue popd -StackName stack_psst return } $text_renaming_files "0.mp3 --> podcast_midinale_$ep`.mp3" Rename-Item "0.mp3" "podcast_midinale_$ep`.mp3" "1.mp3 --> podcast_midinale_$ep`_partie1.mp3" Rename-Item "1.mp3" "podcast_midinale_$ep`_partie1.mp3" "2.mp3 --> podcast_midinale_$ep`_partie2.mp3" Rename-Item "2.mp3" "podcast_midinale_$ep`_partie2.mp3" "3.mp3 --> podcast_midinale_$ep`_partie3.mp3" Rename-Item "3.mp3" "podcast_midinale_$ep`_partie3.mp3" $text_tagging_files $show_date = Read-Host -Prompt $text_prompt_showdate "$text_tagging_one_file podcast_midinale_$ep`.mp3" Set-Id3Tag "podcast_midinale_$ep`.mp3" -Tags @{"Title"="La Midinale de Radio Pikez! $show_date (complet)";"Artists"="Association Pikez!";"Album"="La Midinale";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} "$text_tagging_one_file podcast_midinale_$ep`_partie1.mp3" Set-Id3Tag "podcast_midinale_$ep`_partie1.mp3" -Tags @{"Title"="La Midinale de Radio Pikez! $show_date (partie 1 - presse)";"Artists"="Association Pikez!";"Album"="La Midinale";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} "$text_tagging_one_file podcast_midinale_$ep`_partie2.mp3" Set-Id3Tag "podcast_midinale_$ep`_partie2.mp3" -Tags @{"Title"="La Midinale de Radio Pikez! $show_date (partie 2 - info alternative)";"Artists"="Association Pikez!";"Album"="La Midinale";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} "$text_tagging_one_file podcast_midinale_$ep`_partie3.mp3" Set-Id3Tag "podcast_midinale_$ep`_partie3.mp3" -Tags @{"Title"="La Midinale de Radio Pikez! $show_date (partie 3 - agenda / tout et pas rien)";"Artists"="Association Pikez!";"Album"="La Midinale";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} $text_tagging_additional_files $additional_files = $(Get-ChildItem .\* -Filter "*.mp3" -Exclude "podcast_midinale_$ep`.mp3", "podcast_midinale_$ep`_partie1.mp3", "podcast_midinale_$ep`_partie2.mp3", "podcast_midinale_$ep`_partie3.mp3").Name $additional_files | foreach { $file = $_ $extract_title = Read-Host -Prompt "($_) $text_prompt_extract_title_or_skip" if ( !$extract_title.Equals("i") ) { "$text_tagging_one_file $file" Set-Id3Tag $file -Tags @{"Title"="La Midinale de Radio Pikez! $show_date ($extract_title)";"Artists"="Association Pikez!";"Album"="L'École Volante";"Genres"="Émissions";"Year"="$(Get-Date -UFormat "%Y")"} } } popd -StackName stack_psst } } } while ( $ep.Equals("notfound") -and !$exit ) } # --- exposed functions <# .SYNOPSIS Automatically tags a Radio Pikez! show mp3 file .DESCRIPTION Gets show info from user prompt and automatically tags files in corresponding directory. .PARAMETER ShowsPath Path to all Radio Pikez! shows mp3 files. .EXAMPLE TODO .LINK www.pikez.space #> function Format-Show { param( [Parameter(Mandatory=$false)][String]$ShowsPath="D:\REFERENTIEL_DOCUMENTAIRE_ASSOCIATION_PIKEZ\Radio Pikez\Emissions" ) enter_splash pushd -StackName stack_psst $ShowsPath $exit = $false do { switch (Read-Host -Prompt $text_prompt_whichshow) { { $_ -in $alternative_names_ecolevolante } { $showdir = $directory_ecolevolante } { $_ -in $alternative_names_midinale } { $showdir = $directory_midinale } { $_ -in $alternative_names__dcdcdc } { $showdir = $directory_dcdcdc } { $_ -eq "exit" } { $exit = $true } default { "$text_try_again_or_exit" ; $showdir = "notfound" } } } while ( $showdir.Equals("notfound") -and !$exit ) if ($exit ) { popd -StackName stack_psst exit_ok } if ( @($(ls -Directory).Name).Contains($showdir) ) { pushd -StackName stack_psst $showdir if ( $showdir.Equals($directory_ecolevolante) ) { tag_ecole_volante } if ( $showdir.Equals($directory_midinale) ) { tag_midinale } popd -StackName stack_psst } else { "ERROR : ($(pwd)) $text_error_directory_notfound '$showdir'" exit_miserably } popd -StackName stack_psst exit_ok } <# .SYNOPSIS Automatically tags Radio Pikez! music repository .DESCRIPTION Empty function (does nothing) .EXAMPLE TODO .LINK www.pikez.space #> function Format-Music { enter_splash exit_ok } <# .SYNOPSIS Automatically checks Radio Pikez! music repository for file names and ID3 tags .DESCRIPTION Empty function (does nothing) .EXAMPLE TODO .LINK www.pikez.space #> function Search-UnformattedMusic { enter_splash exit_ok } Export-ModuleMember -function Format-Show, Format-Music, Search-UnformattedMusic |