bherrmann7/Car-Cast — pull request #98 by smblott-github (2013-11-02 14:57:47+00:00)
Title: Priority subscriptions.

Hi Bob,

I've another pull request I hope you'll consider. This one is considerably more complicated than the previous one, so here's a bit of a walk through...

The idea is to add priority subscriptions. I have a long list of subscriptions and a long list of downloaded podcasts. However, there are a couple of subscriptions which -- when there's a new episode -- I absolutely want to listen to it next. In my case, this is typically coverage of multi-day sports events. For somebody else, it might be a daily news briefing or the like.

The idea: add a `priority` checkbox to the subscription activity and have newly-downloaded priority podcasts added immediately after the currently-playing file.

The changes are fairly substantial.

First, I added the checkbox and fixed the code that reads/writes subscriptions such that it can handle both old-style and new-style subscriptions. I see you've made similar changes in the past. Then I pushed the new `priority` property through the download logic such that we know a podcast's priority at the point where it's downloaded.

For priority podcasts, I changed the way file are named. Where previously it was `XXXXX.mp3` (where `XXXXX` is the timestamp) now it's `YYYYY-XXXXX.mp3`, where `XXXXX` is as before, but `YYYYY` is the timestamp of the currently-playing file. The idea is that priority podcasts will just sort into the right place.

Aside: I also changed the sort order from being based on file creation/modification time to being based on the actual file name.

Up to this point, everything works fine. Except if there is a `podcast-order.txt` file present and the currently-playing podcast is one of the files named therein.

So there are two cases. The simple case where the sort on the file name does the trick, and a second case where a newly-encountered file is inserted at the correct position within the initial `metas` list.

Sorry, it's long and a touch tricky. I hope you'll nevertheless take the time to work through it.

Many thanks,
Steve