 |
pyTivo Discussion Forum Answers and the development of pyTivo a TiVo transcoding server
|
|
| Author |
Message |
MasterCephus

Joined: 05 Jan 2008 Posts: 195 Location: Hueytown, AL
|
Posted: Wed Mar 19, 2008 10:34 pm Post subject: Sorting |
|
|
How is sorting handled when viewing a directory via pyTivo?
I have a complete series of a show, with all the available meta data for each show. Now when I view the directory on my Tivo, I get the first episode (a combined eppy 1 and 2), then episodes 10-20, then 3-9.
Any ideas on why this is happening? Am I giving enough information?
One thing to note, and I think others have noticed this, but I do have the proper episode number specified in my meta data file, but it's showing up via Tivo as 0 (every episode is like this). _________________ MetaGenerator
pyTivo Manager |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 1229
|
Posted: Wed Mar 19, 2008 11:16 pm Post subject: |
|
|
It's a simple alphabetic sort by filename. So of course if you have episodes 1 through 10, it would go 1, 10, 2... The solution is to zero-pad any numbers in your filenames that you want to sort "properly".
At one time, armooo had a special sort routine that did a numeric sort if the filenames started with a number. But he broke that when he added the full pathnames to the file lists. Later, I removed the dead code -- I didn't think it would be worthwhile to try and make it work again.
We really do need to get date-based sorting in there, though. _________________ My pyTivo fork |
|
| Back to top |
|
 |
MasterCephus

Joined: 05 Jan 2008 Posts: 195 Location: Hueytown, AL
|
Posted: Wed Mar 19, 2008 11:40 pm Post subject: |
|
|
| Quote: | We really do need to get date-based sorting in there, though. |
It would be nice to sort by original air date. Maybe even an option per share...if you are doing TV series, then you sort by original air date. If you are doing Movies, then simple alphabetic sort would suffice. _________________ MetaGenerator
pyTivo Manager |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Sat Mar 22, 2008 9:35 pm Post subject: |
|
|
| I agree it would be nice to be able to select this option on a per share basis. |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 1229
|
Posted: Sat Mar 22, 2008 10:22 pm Post subject: |
|
|
I don't... I want title and date sorts selected according to the TiVo's own settings. (The TiVo requests the appropriate sort mode in the parameters, but pyTivo's video plugin currently ignores that request.) Then you'd just press "1" to change the sort mode. _________________ My pyTivo fork |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Sun Mar 23, 2008 12:41 am Post subject: |
|
|
Big surprise. I think most people would prefer to sort alphanumerically in their pyTivo shares even though they sort by recording date on their TiVo in general. This is evident by the fact that the current default setup has provoked little comment.
It would be annoying for users to have to constantly hit 1 on their remotes when a simple override is so easy. |
|
| Back to top |
|
 |
MasterCephus

Joined: 05 Jan 2008 Posts: 195 Location: Hueytown, AL
|
Posted: Sun Mar 23, 2008 12:46 am Post subject: |
|
|
| Quote: | I think most people would prefer to sort alphanumerically in their pyTivo shares even though they sort by recording date on their TiVo in general. This is evident by the fact that the current default setup has provoked little comment. |
I think Tivo sorts by the recording date. Since we have no "recording date" then IMO the next best thing is to sort by original air date.
For instance, if I wanted to watch every episode of a season, I want a list sorted by the order to watch them, not to have to have another list on hand to make sure I am watching in order...to achieve that, we have to use original air date. _________________ MetaGenerator
pyTivo Manager |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 1229
|
Posted: Sun Mar 23, 2008 5:35 am Post subject: |
|
|
| krkeegan wrote: | Big surprise. |
Eh? _________________ My pyTivo fork |
|
| Back to top |
|
 |
MasterCephus

Joined: 05 Jan 2008 Posts: 195 Location: Hueytown, AL
|
Posted: Sat Mar 29, 2008 12:23 pm Post subject: |
|
|
So is there any plans to implement a "Sort by Original Airdate" in the mix?
EDIT:
If there is a plan, can I also offer an option for each share to either sort by default (as is right now), or sort by OriginalAirDate?
Just to make clear, this will help TV episodes be sorted by their air date, and then allow a movie share to just be sorted alphabetically. _________________ MetaGenerator
pyTivo Manager |
|
| Back to top |
|
 |
philhu
Joined: 04 Jan 2008 Posts: 239
|
Posted: Sat Mar 29, 2008 11:01 pm Post subject: |
|
|
| wmcbrine wrote: | I don't... I want title and date sorts selected according to the TiVo's own settings. (The TiVo requests the appropriate sort mode in the parameters, but pyTivo's video plugin currently ignores that request.) Then you'd just press "1" to change the sort mode. |
This is exactly what should be done. Whether it is the best way or not, the interface should be consistent and we wont get the tivo way changed.
Pytivo stuff should work just like tivo stuff or tivo to tivo npl stuff
another thing pytivo does not do is put the title inside a folder if necessary, like the tivo does.
If a show is called: The Show, episode title: The episode,
The folder is 'The Show', and inside the episode is 'The Episode'
UNLESS......
The folder is not the show name, such as 'HD Recordings', then the tivo shows it inside the folder as:
The Show: "The Episode"
I asked about this a few months ago, it didnt go very far.  |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Sun Mar 30, 2008 4:42 pm Post subject: |
|
|
| philhu wrote: | Another thing pytivo does not do is put the title inside a folder if necessary, like the tivo does.
If a show is called: The Show, episode title: The episode,
The folder is 'The Show', and inside the episode is 'The Episode'
UNLESS......
The folder is not the show name, such as 'HD Recordings', then the tivo shows it inside the folder as:
The Show: "The Episode"
I asked about this a few months ago, it didnt go very far.  |
The reason you didn't get very fair is we don't control how the information is displayed. pyTivo passes fields to the TiVo, how the TiVo chooses to display these fields is up to it. |
|
| Back to top |
|
 |
MasterCephus

Joined: 05 Jan 2008 Posts: 195 Location: Hueytown, AL
|
Posted: Sun Mar 30, 2008 5:40 pm Post subject: |
|
|
| Quote: |
This is exactly what should be done. Whether it is the best way or not, the interface should be consistent and we wont get the tivo way changed.
|
I understand consistency in the interface, there is a difference there by the way the Tivo handles sorting by date. It handles by the date the show was recorded. It seems that Original Air Date seems to be the only thing pyTivo has that can be used to this measure. _________________ MetaGenerator
pyTivo Manager |
|
| Back to top |
|
 |
goldfndr

Joined: 18 Mar 2008 Posts: 6
|
Posted: Sat May 17, 2008 7:34 am Post subject: Sort by mtime |
|
|
For a quick hack, how about by modification time?
| Code: | diff -u plugin.py.DIST plugin.py
--- plugin.py.DIST 2008-05-16 22:17:23.000000000 -0700
+++ plugin.py 2008-05-17 00:29:15.000000000 -0700
@@ -171,12 +171,17 @@
def name_sort(x, y):
return cmp(x, y)
+ def date_sort(x, y):
+ return cmp(os.stat(y).st_ctime, os.stat(x).st_ctime)
+
if query.get('SortOrder',['Normal'])[0] == 'Random':
seed = query.get('RandomSeed', ['1'])[0]
self.random_lock.acquire()
random.seed(seed)
random.shuffle(files)
self.random_lock.release()
+ elif query.get('SortOrder',['Normal'])[0] == '!CaptureDate':
+ files.sort(date_sort)
else:
files.sort(dir_sort) |
ctime could be used instead (and is used for the originalAirDate default) but mtime might be a little more convenient -- just use touch on each file in order by date!
(diff based on wgw's git) |
|
| Back to top |
|
 |
choekstr

Joined: 06 Dec 2008 Posts: 146
|
Posted: Sun Dec 14, 2008 7:21 pm Post subject: |
|
|
This finally bugged me enough to try out this fix and sure enough, it works like a charm. I have roughly 120 movies that I have in my Video folder and the default sorting of Alphabetical is pretty much useless to me. With the code modifications already posted by goldfndr and a small tweak of my own I was able to get the Tivo to sort either by Alphabetical or by Modified time just by hitting "1" on the Tivo remote or by going into the Enter menu and changing it there. This is how it is designed and supposed to work so I am very surprised it hasn't been changed in the core code or anyone's fork!
Here is my modified code for plugin.py:
| Code: | def name_sort(x, y):
return cmp(x, y)
def date_sort(x, y):
return cmp(os.stat(y).st_mtime, os.stat(x).st_mtime)
if query.get('SortOrder',['Normal'])[0] == 'Random':
seed = query.get('RandomSeed', ['1'])[0]
self.random_lock.acquire()
random.seed(seed)
random.shuffle(files)
self.random_lock.release()
elif query.get('SortOrder',['Normal'])[0] == '!CaptureDate':
files.sort(date_sort)
else:
files.sort(dir_sort)
|
To make the changes, just make a backup of plugin.py, edit the plugin.py and modify the code to reflect what is above. Note I used mtime instead of ctime since I care about when the file was added to my Video folder instead of when the file was created. This gives me the choice of sorting by date now as the Tivo was intended.
Great work goldfndr and wgw and/or wmcbrine, this is worthy of addition to your builds!
Hope this helps others,
Chris |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 1229
|
Posted: Sun Dec 14, 2008 7:50 pm Post subject: |
|
|
I agree, it's the way to go. As you can see above, it had been resisted by KRKeegan. But I think I'll do it now, as soon as I can test it. _________________ My pyTivo fork |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|