Video Library Sorting
#1
I am trying to add a "sort title" field to allow for customized sorting of movies from series (for example, the Harry Potter movies, which end up in the wrong order when sorted alphabetically). I have managed to get the field created in the database and made it settable from an nfo file. I found in xbmc/SortFileItem.cpp where the SSortFileItem::ByMovieTitle is defined and changed it to use my m_strSortTitle instead of m_strTitle, but when I am in the video library, things are still sorted by Title, not SortTitle. Can someone point me to where in the code the sorting for the library is determined? I can't figure out where the sort method is being set. Any help would be appreciated.
Thanks,
Joel
Reply
#2
Sort methods are set in GUIViewStateVideo.cpp. It's probably sorting by label or something.

Sort methods are applied using SSortFileItem class. We first set the sort label (m_sortLabel I think?) and then sort using that.

Note that there is already an "originaltitle" field in the database that may possible be reusable for this - not sure.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
Thanks, I will try to have a look at that tomorrow. I did notice the "originaltitle" and wasn't sure if it was used anywhere. I think that IMDB and TMDB may have info for those fields and I don't know if it would overwrite any custom setting. So, it may be safest to just use my new field.
Thanks,
Joel
Reply
#4
I asked somewhere else that is the 'originaltitle' field accessable for skins? I could use it, but the wiki has no info about it at all. The field set by the .nfo file but I don't find how to read it.

(sorry for the offtopic)
Reply
#5
Okay, I have looked around a bit more, and I think I am starting to get a handle on how it works. My question now is about how LABEL_MASKS() works. I found this part of CGUIViewStateWindowVideoNav which I think I need to modify:

case NODE_TYPE_TITLE_MOVIES:
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%R")); // Filename, Duration | Foldername, empty
else
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R")); // Filename, Duration | Foldername, empty
AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R")); // Filename, Duration | Foldername, empty
AddSortMethod(SORT_METHOD_YEAR,562, LABEL_MASKS("%T", "%Y"));
SetSortMethod(g_stSettings.m_viewStateVideoNavTitles.m_sortMethod);

SetViewAsControl(g_stSettings.m_viewStateVideoNavTitles.m_viewMode);

SetSortOrder(g_stSettings.m_viewStateVideoNavTitles.m_sortOrder);
}
break;

This is in GUIViewStateVideo.cpp. There are a whole lot of LABEL_MASKS() calls with various arguments (%T, %L, %R, %Y, etc.). What I can't find is where those arguments are defined. Can anyone point me to that? I have grepped like crazy through the source tree, but I can't seem to find the proper search term.
Thanks,
Joel
Reply
#6
Nice work finding your way around the maze Smile

%T == Title - they're all in LabelFormatter.cpp/h

So yeah, in this case it's a plain sort by label, with the label being set to the title. You want to replace this with a sort by sorttitle, while keeping the label being set to title.

Thus, change the SORT_METHOD_LABEL to SORT_METHOD_SORT_TITLE or whatever you've called your new method. This method would use the sorttitle if it exists, else drop down to the normal title.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
Sweet. That did the trick. I got a hackish version working by adding a mask for SortTitle. Now I just have to figure out the right way to do it. I will work on the advice you gave me.
Thanks,
Joel
Reply
#8
I would LOVE to see this implemented! I've been waiting for this feature for a long time. Good luck joelmeans and thanks for taking this up.
Reply
#9
Awesome stuff. This is the only thing currently missing from XBMC I feel, and now it isn't!
Reply
#10
Well, I have got it working now. I still have to clean up a few things before I think about submitting a patch. Also, I did my work on the release version (9.04.1), so I need to work on SVN. I also need to read up on the proper way to prepare and submit my patch. I will keep you all updated on my progress.
Joel
Reply
#11
Alright, I just submitted this patch in trac (ticket #7008). The patch is for SVN. I have a patch for 9.04 as well. If people are interested in that, I can post it. That one requires deleting your DB and starting over. The SVN patch will update your DB (if you are moving from 9.04, or an older SVN with DB version < 31). Let me know how this works for you.
Joel
Reply
#12
Thumbs Up 
Thanks sooo much! I've been waiting for this for years! Can't wait to try this out.
Reply
#13
I found this thread in my search for a problem I'm having in XBMC. I don't use library mode and simply have my movies sorted by name. However, and I don't know when this started happening, movies with sequels are not sorting correctly. I'm talking about simple numbered sequels. For example, Pink Panther and Pink Panther 2 are sorted wrong, as are Back To The Future, Back To The Future - Part II and Back To The Future - Part III. The Part II and Part III are sorted correctly but the first movie is listed last. This seems to be a problem with the file system in use by XBMC as my Mac and Windows machines also sorts them the same way, wrong. My Linux box, however, sorts them correctly. This is a fundamental flaw in the alphabetic sorting. It is like "nothing" is set to be last, instead of first, in the sort order. BTTF"nothing".mp4 should be before BTTF - Part II.mp4
Reply
#14
Why are you saying that is wrong, if your mac and windows machines sort things the same way, and only linux sorts them differently?

Have you tried turning file extensions off?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#15
I just do a lil "renaming" of sorts to get my Movies in order of continuity. Works out well......except for movies like Friday, Next Friday, and Friday After Next. Friday and Friday After Next are fine, but Next Friday is in my "N" section.

And with Waiting and Still Waiting.

BUT, we can't have everything we want in life or media centers, right?
Reply

Logout Mark Read Team Forum Stats Members Help
Video Library Sorting0