pyTivo Discussion Forum Forum Index pyTivo Discussion Forum
Answers and the development of pyTivo a TiVo transcoding server
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting
Goto page 1, 2  Next
 
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> pyTivo
 View previous topic :: View next topic  
Author Message
MasterCephus



Joined: 04 Jan 2008
Posts: 173
Location: Hueytown, AL

PostPosted: Wed Mar 19, 2008 2:34 pm    Post subject: Sorting Reply with quote

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
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 514

PostPosted: Wed Mar 19, 2008 3:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
MasterCephus



Joined: 04 Jan 2008
Posts: 173
Location: Hueytown, AL

PostPosted: Wed Mar 19, 2008 3:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
krkeegan
Site Admin


Joined: 04 Jan 2008
Posts: 412
Location: Los Angeles, CA

PostPosted: Sat Mar 22, 2008 1:35 pm    Post subject: Reply with quote

I agree it would be nice to be able to select this option on a per share basis.
Back to top
View user's profile Send private message Visit poster's website
wmcbrine



Joined: 04 Jan 2008
Posts: 514

PostPosted: Sat Mar 22, 2008 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
krkeegan
Site Admin


Joined: 04 Jan 2008
Posts: 412
Location: Los Angeles, CA

PostPosted: Sat Mar 22, 2008 4:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
MasterCephus



Joined: 04 Jan 2008
Posts: 173
Location: Hueytown, AL

PostPosted: Sat Mar 22, 2008 4:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 514

PostPosted: Sat Mar 22, 2008 9:35 pm    Post subject: Reply with quote

krkeegan wrote:
Big surprise.

Eh?

_________________
My pyTivo fork
Back to top
View user's profile Send private message
MasterCephus



Joined: 04 Jan 2008
Posts: 173
Location: Hueytown, AL

PostPosted: Sat Mar 29, 2008 4:23 am    Post subject: Reply with quote

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
View user's profile Send private message
philhu



Joined: 04 Jan 2008
Posts: 122

PostPosted: Sat Mar 29, 2008 3:01 pm    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
krkeegan
Site Admin


Joined: 04 Jan 2008
Posts: 412
Location: Los Angeles, CA

PostPosted: Sun Mar 30, 2008 8:42 am    Post subject: Reply with quote

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. Smile

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
View user's profile Send private message Visit poster's website
MasterCephus



Joined: 04 Jan 2008
Posts: 173
Location: Hueytown, AL

PostPosted: Sun Mar 30, 2008 9:40 am    Post subject: Reply with quote

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
View user's profile Send private message
goldfndr



Joined: 18 Mar 2008
Posts: 6

PostPosted: Fri May 16, 2008 11:34 pm    Post subject: Sort by mtime Reply with quote

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
View user's profile Send private message Visit poster's website
choekstr



Joined: 06 Dec 2008
Posts: 19

PostPosted: Sun Dec 14, 2008 11:21 am    Post subject: Reply with quote

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
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 514

PostPosted: Sun Dec 14, 2008 11:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> pyTivo All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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
Site is in NO WAY affiliated with TiVo Inc

Powered by phpBB © 2001, 2005 phpBB Group
phpBB SEO
[ Time: 0.5323s ][ Queries: 12 (0.3640s) ][ Debug on ]