Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. dirgpodder=YOUR_GPODDER_DOWNLOADS_DIRECTORY
  4. db=~/.config/gpodder/database.sqlite
  5.  
  6.  
  7. cd $dirgpodder
  8.  
  9. for dir in *; do
  10.     if [[ -d "$dir" ]];then
  11.         echo "Processing $dir"
  12.         query='select channels.title from channels where foldername="'$dir'"'
  13.         channel=`sqlite3 "$db" "$query"`
  14.         channel=${channel:-$dir}
  15.         cd "$dir"
  16.        
  17.         for f in *.mp3; do
  18.             [[ -f "$f" ]] || break
  19.             id3v2 -l "$f" 2>&1 | grep 'No ID3 tag' #> /dev/null
  20.             if [[ $? -eq 0 ]]; then
  21.                 query='select episodes.title from channels join episodes on channels.id=channel_id where foldername="'$dir'" and filename="'$f'"'
  22.                 title=`sqlite3 "$db" "$query"`
  23.                 title=${title:-$f}
  24.                 echo "Tagging $dir/$f as $channel, $title"
  25.                 id3v2 -2 -a "$channel" -t "$title" "$f"
  26. #           else
  27. #               query='select episodes.title from channels join episodes on channels.id=channel_id where foldername="'$dir'" and filename="'$f'"'
  28. #               title=`sqlite3 "$db" "$query"`
  29. #               title=${title:-$f}
  30. #               echo "Tagging $dir/$f as $channel, $title"
  31. #               id3v2 -2 -a "$channel" -t "$title" "$f"
  32.             fi
  33.         done
  34.         cd ..
  35.     fi
  36. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement