Add transcript localization support#16
Draft
davelab6 wants to merge 3 commits into
Draft
Conversation
find . -maxdepth 1 -type f -name "*.vtt" \
| while read FILE_PATH; do
# 1. Extract the base video ID and a dash (-)
BASE_NAME=$(basename "$FILE_PATH" .vtt)
# 2. Check if a language-specific version of that video exists
# The grep pattern looks for the BASE_NAME followed by a period and
# at least two non-period characters (the language code) before .vtt
if ls "$BASE_NAME".??*.vtt 2>/dev/null; then
echo "Deleting: $FILE_PATH (Found language-specific duplicate)"
git rm "$FILE_PATH"
fi
done
find . -maxdepth 1 -type f -name "*.vtt" \
| while read FILE_PATH; do
# 1. Extract the base name (everything before the final .vtt)
BASE_NAME=$(basename "$FILE_PATH" .vtt)
# 2. Check if the file is a GENERIC VTT (i.e., its name does NOT contain a language code)
# This uses parameter expansion to check if the basename is the same as the part
# before a language code. If they differ, it is already language-specific.
if [[ "$BASE_NAME" != *".??."* && "$BASE_NAME" != *".??-??."* ]]; then
# Check if a language-specific version of this video ID ALREADY EXISTS
# The glob pattern checks for BASE_NAME followed by a language code (.?? or .??-??)
if ! ls "$BASE_NAME".??*.vtt 2>/dev/null; then
NEW_FILE_PATH="${BASE_NAME}.en-GB.vtt"
echo "Renaming: $FILE_PATH -> $NEW_FILE_PATH"
git mv "$FILE_PATH" "$NEW_FILE_PATH"
fi
fi
done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I got a large set of VTT titles for the latest video