Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Rockbox General
| |-+  Rockbox General Discussion
| | |-+  bash script someone may find useful
« previous next »
  • Print
Pages: [1]

Author Topic: bash script someone may find useful  (Read 1035 times)

Offline Primefalcon

  • Member
  • *
  • Posts: 21
bash script someone may find useful
« on: September 13, 2012, 07:22:17 AM »
I download my podcasts that I listen to using gpodder, but really you could modify the script for whatever... it is all just basic bash after all...

what it does is simply converts the episodes to a format rockbox can read and syns them onto or off the the ipod nano... feel free to take and modify and post back if you add a cool stuff

Code: [Select]
#!/bin/bash

iPodMount="ipod mount point"; #change this to your ipod mount point
gPodderFolder="$HOME/gpodder-downloads"; #change this to your podcast directory

convertEp() {
if [ ! -d "$gPodderFolder/$1/$Rockbox" ]; then mkdir "$gPodderFolder/$1/$Rockbox"; fi
cd "$HOME/Music/gpodder-downloads/$1"

# lets convert all the video files into a format rockbox can play
for f1 in *.mp4; do
f2="${f1%.mp4}.mpeg"

if [ ! -f "Rockbox/$f2" ]; then
avconv -i "$f1" -r 20 -s 176x100 -vcodec mpeg1video -b 250k -ab 92k -ac 2 -ar 44100 -acodec libmp3lame "Rockbox/${f1%.mp4}.mpeg" 2> /dev/null
fi
done

# here we are just going to delete rockbox files that have been removed from gpodder
# I dont need to bother about ogg files since rockbox can read those as downloaded
cd "$HOME/Music/gpodder-downloads/$1/Rockbox"
for rockfile in *.mpeg; do
originalFileName="${rockfile%.mpeg}.mp4"
if [ ! -f "$HOME/Music/gpodder-downloads/$1/$originalFileName" ]; then
rm -v "$rockfile" 2> /dev/null;
fi
done
}

syncEp() {
if [ ! -d "$iPodMount/$1" ]; then mkdir "$iPodMount/$1"; fi


# Lets check both video and audio to see if there are any new files to transfer to ipod

# first the video
if [ $2 == 'video' ]; then
cd "$gPodderFolder/$1/Rockbox";
for rockfile in *.mpeg; do
if [ ! -f "$iPodMount/$1/$rockfile" ]; then
cp -v "$rockfile" "$iPodMount/$1/$rockfile" 2> /dev/null;
fi
done
fi

# now for the audio
if [ $2 == 'audio' ]; then
cd "$gPodderFolder/$1";
for rockfile in *.ogg; do
if [ ! -f "$iPodMount/$1/$rockfile" ]; then
if [ $rockfile != '*.ogg' ]; then cp -v "$rockfile" "$iPodMount/$1/$rockfile" 2> /dev/null; fi
fi
done
fi

# now that we've transferred over new files.... lets see if we can dump any from the ipod
# also we'll get rid of any unused folers, will make it easier to see where eps are on the ipod

# first the video
if [ $2 == 'video' ]; then
cd "$iPodMount/$1";
for rockfile in *.mpeg; do
if [ ! -f "$gPodderFolder/$1/Rockbox/$rockfile" ]; then rm -vvv $rockfile 2> /dev/null; fi
done
rmdir "$iPodMount/$1" 2> /dev/null
fi

# now the audio
if [ $2 == 'audio' ]; then
cd "$iPodMount/$1";
for rockfile in *.ogg; do
if [ ! -f "$gPodderFolder/$1/$rockfile" ]; then rm -vvv $rockfile 2> /dev/null; fi
done
rmdir "$iPodMount/$1" 2> /dev/null
fi

}

# if I just want to convert without touching the ipod (it might not be plugged in)
# so I'll type in at the terminal  (without quotes) "scriptName both"
if [ $1 == convert ]; then
convertEp 'folder 1'
convertEp 'folder 2'
        #and so on......
fi

# if I want to just sync files to the ipod that are currently
# in a format that the ipod can play without doing any converting
# since I might be in a rush and converting takes time
# so I'll type in at the terminal  (without quotes) "scriptName both"
if [ $1 == sync ]; then
syncEp 'folder 1'
syncEp 'folder 2'
        #and so on......
fi

# sometimes I might just want it to do both....
# so I'll type in at the terminal  (without quotes) "scriptName both"
if [ $1 == both ]; then
convertEp 'folder 1'
convertEp 'folder 2'
        #and so on......

syncEp 'folder 1'
syncEp 'folder 2'
        #and so on......
fi
« Last Edit: September 13, 2012, 07:36:13 AM by Primefalcon »
Logged

Offline AlexP

  • Global Moderator
  • Member
  • *
  • Posts: 3688
  • ex-BigBambi
Re: bash script someone may find useful
« Reply #1 on: September 13, 2012, 02:06:29 PM »
Thanks, but this will get lost on the forums.  The wiki might be a better place for it.
Logged
H140, F60, S120, e260, c240, Clip, Fuze v2, Connect, MP170, Meizu M3, Nano 1G, Android

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox General
| |-+  Rockbox General Discussion
| | |-+  bash script someone may find useful
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.064 seconds with 15 queries.