diff options
| -rwxr-xr-x | bin/srtrename | 62 | ||||
| -rw-r--r-- | nvimrc | 5 | ||||
| -rw-r--r-- | vimrc | 4 |
3 files changed, 28 insertions, 43 deletions
diff --git a/bin/srtrename b/bin/srtrename index 33166e8..535f4eb 100755 --- a/bin/srtrename +++ b/bin/srtrename @@ -1,42 +1,30 @@ #!/bin/bash -# Enable debug output -set -x - -# Loop through all subtitle files for srt in *.srt; do - # Skip if no .srt files found - [[ -f "$srt" ]] || { echo "No .srt files found"; exit 1; } - - echo "Processing subtitle file: $srt" - - # Extract the episode number (S01E04) - more specific pattern - episode=$(echo "$srt" | grep -o "S[0-9]\{2\}E[0-9]\{2\}") - echo "Extracted episode number: $episode" - - # Find the corresponding video file - video_file=$(find . -maxdepth 1 -type f -name "*${episode}*.mkv") - echo "Found video file: $video_file" - - # If a matching video file is found - if [[ -n "$video_file" ]]; then - # Remove the .mkv extension and leading ./ - video_basename=$(basename "$video_file" .mkv) - # Create new subtitle name - new_name="${video_basename}.srt" - - echo "Will rename '$srt' to '$new_name'" - - # Only rename if the new name is different - if [[ "$srt" != "$new_name" ]]; then - mv -v "$srt" "$new_name" - else - echo "File already has the correct name" - fi - else - echo "No matching video file found for '$srt'" - # List all mkv files for debugging - echo "Available mkv files:" - ls -l *.mkv + [[ -f "$srt" ]] || { echo "no .srt files found"; exit 1; } + + episode=$(echo "$srt" | grep -o "S[0-9]\{2\}E[0-9]\{2\}") + if [[ -z "$episode" ]]; then + echo "no episode number found in '$srt'" + exit + fi + + video_file=$(find . -maxdepth 1 -type f -name "*${episode}*.mkv") + if [[ $video_file == '' ]] then + epnumber=$(echo "$episode" | head -c6 | tail -c2) + echo "no matching video file found for '$episode', trying ep number $epnumber..." + video_file=$(find . -maxdepth 1 -type f -name "* ${epnumber} *.mkv") + fi + + if [[ -n "$video_file" ]]; then + echo "found video file: $video_file" + video_basename=$(basename "$video_file" .mkv) + new_name="${video_basename}.srt" + + if [[ "$srt" != "$new_name" ]]; then + mv -v "$srt" "$new_name" fi + else + echo "no matching video file found for '$srt'" + fi done @@ -2,7 +2,7 @@ let g:mapleader = '\' let g:vsnip_snippet_dir = '~/.config/nvim/snippets' " fuck zig niggers let g:polyglot_disabled = ['autoindent'] - +let g:tabby_keybinding_accept = '<Tab>' lua <<EOF local Plug = vim.fn['plug#']; vim.call('plug#begin'); @@ -22,7 +22,7 @@ lua <<EOF Plug('nvim-telescope/telescope.nvim', { tag = '0.1.8' }) Plug('hrsh7th/cmp-vsnip') Plug('hrsh7th/vim-vsnip') - Plug('TabbyML/vim-tabby') + Plug('navewindre/vim-tabby') Plug('Yggdroot/indentLine') Plug('johnfrankmorgan/whitespace.nvim') Plug('sheerun/vim-polyglot') @@ -489,7 +489,6 @@ function! TablineTabs() return lightline#tabline() endfunction -let g:tabby_keybinding_accept = '<Tab>' autocmd Filetype json,jsonc let g:indentLine_setConceal = 0 autocmd Filetype javascriptreact,typescriptreact TSEnable indent autocmd Filetype * call tabby#inline_completion#keybindings#Setup() @@ -2,9 +2,7 @@ let g:mapleader = '\' let g:vsnip_snippet_dir = '~/.config/nvim/snippets' " fuck zig niggers let g:polyglot_disabled = ['autoindent'] - call plug#begin() - Plug 'chriskempson/base16-vim' Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/cmp-nvim-lsp' @@ -18,7 +16,7 @@ Plug 'mengelbrecht/lightline-bufferline' Plug 'preservim/nerdtree' Plug 'hrsh7th/cmp-vsnip' Plug 'hrsh7th/vim-vsnip' -Plug 'TabbyML/vim-tabby' +Plug 'navewindre/vim-tabby' Plug 'Yggdroot/indentLine' Plug 'johnfrankmorgan/whitespace.nvim' Plug 'sheerun/vim-polyglot' |
