Coder Social home page Coder Social logo

ipod-shuffle-4g's Introduction

IPod Shuffle 4g Script

ipod-shuffle-4g.py

Python script for building the Track and Playlist database for the newer gen IPod Shuffle. Forked from the shuffle-db-ng project and improved my nims11 and NicoHood.

Just put your audio files into the mass storage of your IPod and shuffle.py will do the rest.

$ ./ipod-shuffle-4g.py --help
usage: ipod-shuffle-4g.py [-h] [-t] [-p] [-u] [-g TRACK_GAIN]
                          [-d [AUTO_DIR_PLAYLISTS]] [-i [ID3_TEMPLATE]] [-v]
                          path

Python script for building the Track and Playlist database for the newer gen
IPod Shuffle. Version 1.5

positional arguments:
  path                  Path to the IPod's root directory

optional arguments:
  -h, --help            show this help message and exit
  -t, --track-voiceover
                        Enable track voiceover feature
  -p, --playlist-voiceover
                        Enable playlist voiceover feature
  -u, --rename-unicode  Rename files causing unicode errors, will do minimal
                        required renaming
  -g TRACK_GAIN, --track-gain TRACK_GAIN
                        Specify volume gain (0-99) for all tracks; 0 (default)
                        means no gain and is usually fine; e.g. 60 is very
                        loud even on minimal player volume
  -d [AUTO_DIR_PLAYLISTS], --auto-dir-playlists [AUTO_DIR_PLAYLISTS]
                        Generate automatic playlists for each folder
                        recursively inside "IPod_Control/Music/". You can
                        optionally limit the depth: 0=root, 1=artist, 2=album,
                        n=subfoldername, default=-1 (No Limit).
  -i [ID3_TEMPLATE], --auto-id3-playlists [ID3_TEMPLATE]
                        Generate automatic playlists based on the id3 tags of
                        any music added to the iPod. You can optionally
                        specify a template string based on which id3 tags are
                        used to generate playlists. For eg. '{artist} -
                        {album}' will use the pair of artist and album to
                        group tracks under one playlist. Similarly '{genre}'
                        will group tracks based on their genre tag. Default
                        template used is '{artist}'
  -v, --verbose         Show verbose output of database generation.

Dependencies

This script requires:

Optional album/artist and auto-id3-playlists support:

Optional Voiceover support

Ubuntu

apt-get install python3 python-mutagen libttspico*

Arch Linux

From the Extra repository: pacman -S python and optional pacman -S python-mutagen espeak or from the AUR: svox-pico-bin (link)

You can also install the script from AUR.

Gentoo Linux
PYTHON_TARGETS="python3" emerge -av media-libs/mutagen
layman --add=ikelos
layman --overlays="https://raw.githubusercontent.com/ahippo/rhvoice-gentoo-overlay/master/repositories.xml" --fetch --add=ahippo-rhvoice-overlay
ACCEPT_KEYWORDS="~amd64" emerge -av app-accessibility/svox app-accessibility/rhvoice

References to the overlays above: ikelos, ahippo-rhvoice-overlay

Tips and Tricks

Disable trash for IPod

To avoid that linux moves deleted files into trash you can create an empty file .Trash-1000. This forces linux to delete the files permanently instead of moving them to the trash. Of course you can also use shift + delete to permanently delete files without this trick. The file can be found in the extras folder.

Compress/Convert your music files

(#11) Shuffle is short on storage, and you might want to squeeze in more of your collection by sacrificing some bitrate off your files. In rarer cases, you might also possess music in formats not supported by your ipod. Although ffmpeg can handle almost all your needs, if you are looking for a friendly alternative, try Soundconverter.

Use Rhythmbox to manage your music and playlists

As described in the blog post you can use Rythmbox to sync your personal music library to your IPod but still make use of the additional features this script provides (such as voiceover).

Simply place a file called .is_audio_player into the root directory of your IPod and add the following content:

name="Name's IPOD"
audio_folders=iPod_Control/Music/

The file can be found in the extras folder.

Now disable the IPod plugin of Rhythmbox and enable the MTP plugin instead. You can use Rythmbox now to generate playlists and sync them to your IPod. The script will recognize the .pls playlists and generate a proper iTunesSD file.

Known Rhythmbox syncing issues
  • Creating playlists with names like K.I.Z. will fail, because the FAT Filesystem does not support a dot . at the end of a directory/file.
  • Sometimes bad ID3 tags can also cause corrupted playlists.

In all cases you can try to update Rythmbox to the latest version, sync again or fix the wrong filenames yourself.

Carry the script with your IPod

If you want to use this script on different computers it makes sense to simply copy the script into the IPod's root directory.

Format/Restore/Recover IPod

(#41) If you formatted your IPod wrong and lost all data you can still recover it. It is important to not use MBR/GPT. You need to directly create a Fat16 Filesystem:

sudo mkfs.vfat -I -F 16 -n IPOD /dev/sdX

Run this script to generate the new database. All missing sound files should be regenrated by the IPod on next use. Your IPod should work and play music again now.

TODO

  • Last.fm Scrobbler
  • Qt frontend

EXTRA READING

The original shuffle3db website went offline. This repository contains a copy of the information inside the docs folder. Original data can be found via wayback machine.

ipod-shuffle-4g's People

Contributors

ahippo avatar babymastodon avatar fracai avatar josefnpat avatar nicohood avatar nims11 avatar thomas-hori avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipod-shuffle-4g's Issues

Add file compression

I am wondering if it would be possible to place the mp3 file in a directory outside the ipod and then transfer them. We could then also reduce the filesize with compressing the files.

Itunes also has this option and I really appreciated this. I normally only have 320kb/s mp3, but on an ipod it its really low space. Having an option for 192kb/s or others would be really nice. If you dont need to manually do it and just select a folder from your music library, copy and shrink it, that'd be perfect.

Any chance to see this?

Switch to python3

2to3 -w filename.py can be used to autoconvert the script. However this gives a few errors, as not all is translated correct.

Edit: it took some time but I think i managed to get the code working. I have not tested all options yet though. Please test release 1.5

relative filenames in m3u playlists

If /path/to/ipod/music/artist/playlist.m3u has abc.mp3, it should consider /path/to/ipod/music/artist/abc.mp3 rather than throwing an error.

Voiceover per playlists and tracks

I'd like to discuss the voiceover feature:
If you ask me I prefer to disable it by default. This also makes the script independent from any voiceover dependencies. Voiceover just uses more storage capacity of the limited 2gb. So why not disable it by default?

And the 2nd point is: We could enable voiceover for tracks and playlists separately. This gives us a lot advantages:

  • Only use playlist voiceover to find the correct playlist out of the 1000 playlists we have, but save memory for tracks
  • Only enable it for tracks to only use it if you need to. Playlists dont use the "ugly" voice. (How Itunes does it)
  • Use both cause you want to have voiceover an everything

So we need to add those features:

  • Switch disable to enable
  • New parameter names (enable voiceover for tracks/playlists)
  • Separate between tracks and playlists implementation

it's not generating an index

My procedure:
-remove all the files from the shuffle
-boot in windows so it regenerates the control folder
-boot in linux and copy a folder to the mount point of the ipod, then run the script

# /root/.p/ipod-shuffle-4g/2016q4/ipod-shuffle-4g.py . 
# the pwd is the mount point where the control folder is and where my music folder is placed as well

drwxr-xr-x 2 root root 16K Jan  1  2016 dos-ep
drwxr-xr-x 6 root root 16K Mar 22 14:06 iPod_Control

the output is:
Database written successfully:
Tracks 0
Albums 0
Artists 0
Playlists 0

Question for usuage of the tool

Hi everyone, I'm sorry for making an extra issue for this.
I just wanted to ask, if that is the right way to use the tool:

  • I plug in my iPod Shuffle (4th Gen) & put all my mp3-files in the root directory
  • Then I execute the script by also specifying the path to the root directory of the iPod

Also do I need to keep the mp3-files in the root directory after the script ran through or can I remove them?
Sorry those questions might be obvious to many people, it's just for my understanding.

Playlist files not ignored when using -d or -i

Example:
I've got a dir with a m3u file within an directory. When using -d switch, said directory produces 2 playlists: one from the dir, another from the playlist file.
Same for id3 option.

Expected behaviour:
m3u / pls / any other supported playlist type should be ignored when using -d / -i switch.

Automatically find ipod directory

I am so lazy I just want to automatically find the ipod directory. We could just scan all available mount points and check for s specific folder structure there. If more than 2 mountpoints suits we can make a selection or simply abort and give a message that more than 1 was found and you need to specify which you want to use.

Catch Ctrl + C

If you interrupt the program it will output some errors. There should be a way to catch this and shut down properly (aka closing all file handles).

Certain files added to DB but not recognized by IPOD (Unicode problem?)

This might be related to #4

When syncing my files with rhythmbox and this script, I realized that some files are correctly added to the DB but the iPod does not recognize them and, for example skips the according playlist.

I explored the issue a little bit further and I found that it occurs when non-standard characters like "ó" are found in the filename or an ID3 tag field. The interesting thing is, after I updated tags with Easytag for both v1 and v2 to be UTF-8, the file was recognized.

I guess one can easily implement a function to rewrite the tags but I wanted to ask if someone else stumbled over the same problem and knows what actually is the problem.

Broken (.pls) playlist track paths gives error

Traceback (most recent call last):
  File "./shuffle.py", line 576, in <module>
    shuffle.write_database()
  File "./shuffle.py", line 512, in write_database
    f.write(self.tunessd.construct())
  File "./shuffle.py", line 212, in construct
    play_header = self.play_header.construct(self.track_header.tracks)
  File "./shuffle.py", line 350, in construct
    construction = playlist.construct(tracks)
  File "./shuffle.py", line 451, in construct
    position = tracks.index(self.ipod_to_path(i))

ValueError: "/media/linuxuser/NICO'S IPOD/music/k.i.z./ganz oben/01 - duhastaufdeinenkokaturndeinegeistigbehinderteschwestergefiktmucke.mp3" is not in list

I used this within a playlist, that gave me the error. Not using playlists is file. I guess its just a too long name (or path!!) of the song. And yeah, that is an official name. K.I.Z. fucked you again ;D

GPG signatures for source validation

As we all know, today more than ever before, it is crucial to be able to trust our computing environments. One of the main difficulties that package maintainers of Linux distributions face, is the difficulty to verify the authenticity and the integrity of the source code.

The Arch Linux team would appreciate it if you would provide us GPG signatures in order to verify easily and quickly of your source code releases.

Overview of the required tasks:

Additional Information:

Thanks.

[Feature Request] Create playlists by folders

It would be nice to create a playlist for each folder. Or at least somehow set a marker.

Lets say you have:

Eminem
 -album1
 -album2
 -album3
David Guetta
 -album1
 -album2

It would be nice to have per interpret playlists. But maybe one also only want a single album as playlist. So maybe placing a .playlist inside the folder just creates a playlist for the folder and all its subfolders.

Another question:
Is it also possible to enable voiceover for playlist names (havent tried voiceover yet)? The best would be to use voiceover for playlists but not for the songs as it takes too much data. But then you could have tons of playlists which are not names just "playlist 1,2,3...".

Support for non-ASCII characters in playlists

Rhythmbox organizes files inside iPod using ID3 tags. ID3 tags has UTF8 characters, as "é", ´"á", "ã", etc. The .pls files and .mp3 files are right in iPod, but IPod-Shuffle-4g, when creating playlists in database, ignore this files.

Catch no space left error

Traceback (most recent call last):
  File "/usr/bin/ipod-shuffle-4g", line 739, in <module>
    shuffle.write_database()
  File "/usr/bin/ipod-shuffle-4g", line 631, in write_database
    f.write(self.tunessd.construct())

Edit: This happens if the generated voiceover files exceed the space left on the ipod. Affects v1.3

Add releases + changelog

Since we fixed some issues and are going to fix a lot more, it would make sense to keep track of it.

I suggest to start from v1.0 (the original code you forked) and add a list of the fixes you made so far. After that you can tag new releases here:
https://github.com/nims11/IPod-Shuffle-4g/releases

Btw thx for looking into the othe issues I opened. I am currently trying to fix this disabled voiceover thing. Also I sent you an email some time ago, you must have missed it?

Generating playlists by Genre issues

I'm trying to generate two different voiceover playlists for two different Genres of music. I want one for Rock, and one for Soundtrack.

However, it's not accepting playlists set up by Banshee OR Rhythmbox, with the -p and -t options.
It also won't accept any .m3u or .pls because of the relative files.
-i Rock does not work, or does -i {Genre}.

This is probably my fault because I misinterpreted the instructions, but they are still unclear. Any advice?

review of ipod-shuffle-4g

I mounted the device, copied the music over in mp3 format, ran ipod-shuffle-4g.py on the mounted directory, unmounted the device. Now I can listen to all the songs, no complications, no GUIs.
Thank you so much! It was about time, I hated Apple's iTunes, that slow bloated piece of fing s.

Use default Speaker when voiceover is disabled

Normally you hear a male speaker if no voiceover was selected via ITunes. Those sound files are still there ./NICO'S IPOD/iPod_Control/Speakable/Messages/.

However I checked my old Ipod backup and it seems the ipod does not generate any database for this "non voiceover" ipod settings from itunes. So there must be a way to use the internal voices without merging the sounds and doing complicated stuff.

If I disable voiceover with your tool I only get "Playlist zero" for ALL playlists. "All Songs" disappeared and is silent.

We should be able to fix this somehow. This also means we do not have to provide the closed source male speaker voiceover, which is great. I will look at the hex output with xxd. But I have nothing more than my backup. Not even a windows PC I could use to regenerate Itunes files.

How to format/restore iPod Shuffle 4G?

First off, thank you for sharing this absolutely fantastic little script, and I hope I can be forgiven for asking for help here, although this isn't strictly a bug:

This morning, my iPod was "full" – really, the hidden Trash folder was, but I didn't know of its existence at the time. Annoyed and a bit cavalierly, I reformatted the device (as GPT with a single FAT partition). Now I can add files again and run your script without problems. However, when I switch the thing on the LED lights up red and the voice says "Please use iTunes to restore this iPod."

I am hoping that someone might be able to share their partition configuration with me, and chime in with any ideas about what exactly the iPod firmware may be looking for? 🙇‍♂️

[Request] Convert FLAC to alac (m4a)

It would be a nice feature to automaticly convert flac to m4a (or any other lossless ipod compatible format).
I've got a lots of flac albums which I had encoded a while ago and I don't really want to encode them all once again.

gTTS support

gTTS (Google Text-to-Speech) can provide very naturally sounding TTS. Would you be interested in gTTS support? I can program this if a pull request would be accepted.

Playlists are not found

First thank you for your amazing work! I love my iPod Shuffle 4 and wouldn't be able to sync it nowadays without this script.

Lately I have some problems generating the playlists on the iPod. I use Rhythmbox to sync, and they are also detected by gtkPod. However some randomly pop up with the name Playlist 0 for example.

Might this be caused during the latest update? I have also switched to Fedora, so the problem might also be there.

UnicodeDecodeError

Hello,

This is a great script! It worked fine the first time. But now I added more music files and it throws an error after processing some files:

$ python shuffle.py --disable-voiceover /media/IPOD/
...
[*] Adding track /media/IPOD/Lágrimas e chuvas.mp3
Traceback (most recent call last):
  File "shuffle.py", line 480, in <module>
    shuffle.write_database()
  File "shuffle.py", line 435, in write_database
    f.write(self.tunessd.construct())
  File "shuffle.py", line 143, in construct
    track_header = self.track_header.construct()
  File "shuffle.py", line 178, in construct
    track.populate(i)
  File "shuffle.py", line 249, in populate
    self["dbid"] = hashlib.md5(text.encode("ascii", "ignore")).digest()[:8] #pylint: disable-msg=E1101
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
$

I am guessing it has something do do with the accented characters..

Do you have any idea how to solve this?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.