[Question] GetMovieCategories broken? (1 Viewer)

Lightning303

MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Hey,
    so i was trying to get the category list for movies (MovingPictures), e.g. the category Year.

    Using http://192.168.1.10:4322/MPExtended/MediaAccessService/json/GetMovieCategories?provider=3 i was expecting something like [{..., "Year":["1960s", "1970s",...],...}], however i get [] (nothing).

    Logs show nothing aswell. So is GetMovieCategories broken? Or does it do something else? How could i get what i want?

    Thanks :).
     

    Oxan

    Retired Team Member
  • Premium Supporter
  • August 29, 2009
    1,730
    1,124
    Home Country
    Netherlands Netherlands
    Yeah, all the category stuff isn't implemented yet. It turned out to be a lot harder than expected to extract the categories from the MovPics database.

    Implementing decade filters is possible though, it's just not obvious at all. With a call to GetFilterValues?provider=3&mediaType=0&filterField=Year&op=^=&limit=3, you should get a list of decades, lacking the last zero (something like [ "196", "197", "198", "199", "200", "201" ]). Then, you can get a list of movies in a given decade with GetMoviesBasic?provider=3&filter=Year>=2010,Year<=2019. The filter stuff is quite-underdocumented, I hope to write a guide somewhere next month. For now, just ask if you've any questions.
     
    Last edited:

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Ah ok, thanks.
    Havent had a chance to look at GetFilterValues, will have a deeper look later. I was pretty sure it would be possible to work around, but liked to use the cleaner way.

    What is your problem with extracting the categories from the database? Maybe i can help out there? When accessing the database directly i had no big problems extracting these information.
     

    Oxan

    Retired Team Member
  • Premium Supporter
  • August 29, 2009
    1,730
    1,124
    Home Country
    Netherlands Netherlands
    What is your problem with extracting the categories from the database? Maybe i can help out there? When accessing the database directly i had no big problems extracting these information.
    Well, for one, they're storing a tree in the database (node__node table), which is always hard to read without either losing your performance or writing quite some code. The fact that the top two nodes of the tree are stored in different tables (menu__node and menu) doesn't make it easier. There also seem to be two menus with the exact same content, which is quite confusing to me.

    Then you need to go from the node table to actual filtering of movies.. which is hard. That seems to be either done by referencing a field on a class with a weird syntax in the basicfilteringfield column (that's great, but we can't do anything with class references), or by referencing a filter in the filters table. Those filters are linked to the criteria table, which again has the field-on-class reference thing, something I really don't understand in the relation column, and another class reference in generic_type. There's also a custom syntax for timespans in the value column and a few operators we'd need to implement.

    It's probably doable, but it's just a lot of work I don't want to invest into it at this moment, especially since we don't gain much with it (most features are also possible with our own API). Patches are always welcome.

    Yes, it'd be better if we could just use the MovingPictures DLL and let them do all the hard work (i.e. just use their programming interface instead of the database). However, we've only recently gained the ability to load DLLs linked against MP in the service, and I'm a bit afraid it'll kill performance.
     

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Yeah the movingpictures db can be quite complicated ;p. Luckily i visited a lecture for databases last semester at my university and now have less problems understanding the structure.
    I cant really help you with the filtering itself, however i think it would be ok if the client would just take the results of GetMovieCategories and use them in the filter parameter in the GetMoviesBasic request.

    However i wanted to help fix GetMovieCategories ;P
    So, i just did a quick test in php (my weapon of choice) to filter out all the categories and the entries in them.

    SQL
    SQL:
    SELECT node.name AS CategoryName FROM menu, menu__node, node WHERE menu.name = "Categories Menu" AND menu.id = menu__node.menu_id AND menu__node.node_id = node.id;

    this results in a list of all categories
    Code:
    ${AllMovies}
    ${UnwatchedMovies}
    ${RecentlyAddedMovies}
    ${Genres}
    ${Year}
    ${Certification}


    Using this sql command
    SQL:
    SELECT node1.name AS CategoryName, node2.name AS CategoryItem FROM menu, menu__node, node node1, node__node, node node2 WHERE menu.name = "Categories Menu" AND menu.id = menu__node.menu_id AND menu__node.node_id = node1.id AND node1.id = node__node.node1_id AND node__node.node2_id = node2.id"

    i get the entries in the categories aswell (not the movies, but lets say the sub categories)
    Code:
    ${Genres}, Action
    ${Genres}, Adventure
    ${Genres}, Animation
    ${Genres}, Biography
    ${Genres}, Comedy
    ${Genres}, Crime
    ${Genres}, Documentary
    ${Genres}, Drama
    ${Genres}, Family
    ${Genres}, Fantasy
    ${Genres}, History
    ${Genres}, Horror
    ${Genres}, Music
    ${Genres}, Musical
    ${Genres}, Mystery
    ${Genres}, Romance
    ${Genres}, Sci-Fi
    ${Genres}, Short
    ${Genres}, Sport
    ${Genres}, Thriller
    ${Genres}, War
    ${Genres}, Western
    ${Year}, 1960s
    ${Year}, 1970s
    ${Year}, 1980s
    ${Year}, 1990s
    ${Year}, 2000s
    ${Year}, 2010s
    ${Certification}, G
    ${Certification}, NC-17
    ${Certification}, NR
    ${Certification}, PG
    ${Certification}, PG-13
    ${Certification}, R

    Performance wise, when using these two sql statements and outputting the data it takes 0.002 seconds.

    Hope that helps :).
     

    Oxan

    Retired Team Member
  • Premium Supporter
  • August 29, 2009
    1,730
    1,124
    Home Country
    Netherlands Netherlands
    From a quick glance, I see two problems with your approach. First of all, you hardcode a depth of 3 levels: the main menu ("Categories Menu"), the items in the menu (year, genres, certification, etc), and the values of these items. The database structure seems to support deeper nested menus though. I'm not sure whether that's used in practice though.

    A bigger problem is filtering the movie list itself for these categories. There needs to be a way to create a list of all movies in a category (or all categories for a movie). That's the hardest part: this is where the criteria table with its classnames etc comes into play.

    Reusing the filter parameter for this isn't really possible. I'd like to make categories generic and, if the source database supports it, allow user-definied categories with arbitrary items in them. For MoPi it might work to let the client build the filter parameter based on a list of all categories (though it'd be complicated for ${Year}, as you need to map 1960s to Year>=1960,Year<=1969), but I don't want that to be the interface. Also, it doesn't work for the recently-added category and categories like that.
     
    Last edited:

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    From a quick glance, I see two problems with your approach. First of all, you hardcode a depth of 3 levels: the main menu ("Categories Menu"), the items in the menu (year, genres, certification, etc), and the values of these items. The database structure seems to support deeper nested menus though. I'm not sure whether that's used in practice though.

    Yes you are right, i didnt think of that.
    Just added some dummy categories in movpic. They can go quite deep. No idea if anybody uses it. As a quick easy work around, you could do a sql reqeust for each level.
    So no we did level 1, a category and an item. after that you could make another reqeust but you filter for the categories with level 2 and so on. do that 5 times and you should catch everything. I mean who uses categories with more levels than 5? Its not very nice but would work.
    Another idea would be to request every parent -> child constellation and then sort them in code by the ids. This would catch every possibility, but would require some coding.At least these are the two ideas i came up with. I will give it a shot later.

    A bigger problem is filtering the movie list itself for these categories. There needs to be a way to create a list of all movies in a category (or all categories for a movie). That's the hardest part: this is where the criteria table with its classnames etc comes into play.
    I agree, however i think we have 2 different views on GetMovieCategories. For me, i expect it to show me only the categories, and not the results of them (the movies). It seems that you would want to include the movies aswell. Especially when thinking of custom categories with custom filters i dont think that you can filter the movies without the movpic interface you mentioned above.
     

    DieBagger

    Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    39
    Austria
    Home Country
    Austria Austria
    A bigger problem is filtering the movie list itself for these categories. There needs to be a way to create a list of all movies in a category (or all categories for a movie). That's the hardest part: this is where the criteria table with its classnames etc comes into play.

    I agree, however i think we have 2 different views on GetMovieCategories. For me, i expect it to show me only the categories, and not the results of them (the movies). It seems that you would want to include the movies aswell. Especially when thinking of custom categories with custom filters i dont think that you can filter the movies without the movpic interface you mentioned above.

    Wouldn't it be quite pointless to have the categories if there is no way to then get the resulting movies?
     
    Last edited:

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    A bigger problem is filtering the movie list itself for these categories. There needs to be a way to create a list of all movies in a category (or all categories for a movie). That's the hardest part: this is where the criteria table with its classnames etc comes into play.



    I agree, however i think we have 2 different views on GetMovieCategories. For me, i expect it to show me only the categories, and not the results of them (the movies). It seems that you would want to include the movies aswell. Especially when thinking of custom categories with custom filters i dont think that you can filter the movies without the movpic interface you mentioned above.



    Wouldn't it be quite pointless to have the categories if there is no way to then get the resulting movies?


    mh, i suppose you are right. Especially for custom categories. But you are able to get the resulting movies for the standard categories with the filter parameter. Let me explain where i am coming from.
    I want to have a Category list with just the basic categories. All Movies, Unwatched Movies, Genres, Years, Certification.
    And with these categories i later want to filter my movies by using the filter parameter in GetMoviesBasic.
    My initial problem was that i couldnt get a list of the Years. All Movies i can do without a categorie. Unwatched is not possible atm, as watched flag is not supported. But i would just filter for watched flag equals 0 or 1. For Genres there is an extra command GetMovieGenres (which aswell does not include the movies for the genres btw.) and later i would filter for the genre i selected. Certification is not supported yet, so i didnt bother. That leaves Years, the filtering itself is again easy, filter=Year^=(first 3 chars from the years e.g. 198).

    So, me personaly, i only expected ever to get a list of the categories when using GetMovieCategories, like i do with genres when using GetMovieGenres. The filtering itself i would then do with the filter parameter.
    I also dont need the movies when requesting the categories. This would be the next step, when actually picking one of the categories.

    Additionaly i dont think it is a good idea to add the resulting movies here. a GetMovieCategories request would result in me getting thousands of results. every movie would be listed in all moves, a lot in unwatched, every movie again in gernes, and ever more then once here, every movie again in years and in certification. So im not sure this is the way to got. But maybe im just naive ;p
     

    Oxan

    Retired Team Member
  • Premium Supporter
  • August 29, 2009
    1,730
    1,124
    Home Country
    Netherlands Netherlands
    I see what you want to do, but only implementing GetMovieCategories is just solving half of the problem. It will require the client to manually convert a category to the filter parameter for that category. That's not something I want that client developers have to do. I want to expose a clean API for clients, where they can retrieve all categories and directly, without having to do any complicated operations, retrieve the movies in the category. Something like GetMoviesBasic?filter=Categories*=1960s. That makes it generic too, and not limited to the set of categories implemented by the client.

    Another problem with only implementing GetMovieCategories is that it doesn't actually solve any problem. If you want to create a category tree with limited options (like you want to do), you can already do that with GetFilterValues. The advantages of GetMovieCategories over GetFilterValues is that it's generic (you can define categories based upon arbitrary conditions, and even have custom categories), and that it is simple to implement for client developers. Neither of those are true if you don't implement a method to retrieve all movies in a category.

    That said, I don't oppose your idea about GetMovieCategories at all. It's something that's on our TODO-list, though not very high. The problem is simply that I personally won't invest any time in only implementing GetMovieCategories, since I don't see the benefits of it. I want to implement the full functionality, which includes retrieving movies from a category. But at the moment, I don't have time to do that, so it hasn't happened yet. However, that doesn't mean that I'm opposed to a partial implementation (i.e. only implementing GetMovieCategories): I'd be more than happy to merge a patch or pull request that implements it.

    That leaves Years, the filtering itself is again easy, filter=Year^=(first 3 chars from the years e.g. 198).
    The ^= operator doesn't work on the Year field, since it's an integer and not a string. You'll need to do filter=Year>=1980,Year<=1989.

    Additionaly i dont think it is a good idea to add the resulting movies here. a GetMovieCategories request would result in me getting thousands of results.
    No, you're right, the movies won't be returned by GetMovieCategories, I want another method to retrieve the movies in a category (or more likely, it'll be a filter option, e.g. filter=Categories*=1960s).
     
    Last edited:

    Users who are viewing this thread

    Top Bottom