OnlineVideos JSON parsing

Discussion in 'OnlineVideos' started by howudodat, December 6, 2015.

  1. howudodat

    howudodat Portal Pro

    Joined:
    February 20, 2007
    Messages:
    75
    Likes Received:
    2
    Ratings:
    +2 / 0
    Home Country:
    United States of America United States of America
    I am trying to create a generic site for OnlineVideos. The site returns JSON for categories, subcategories and videos. I have the categories working and subcategories partially. The problem I am having is how to ignore the first description and only process the subcategories array. Here is my regex, and the JSON

    Code (Text):
    1. {"description":"(?<description>[^"]*)","key":"(?<url>[^"]*)","name":"(?<title>[^"]*)","type(?:(?!vert).)*"vert(?:(?!sm").)*sm":"(?<thumb>[^"]*)",(?:(?!}},).)*}},
    Code (Text):
    1. {
    2.     "category": {
    3.         "description": "useless category description",
    4.         "key": "useless category key",
    5.         "name": "Useless Category Name",
    6.         "type": "container",
    7.         "tags": ["cat tag"],
    8.         "images": {
    9.            
    10.         },
    11.         "subcategories": [{
    12.             "description": "Description1",
    13.             "key": "subcat1",
    14.             "name": "SubCat 1",
    15.             "type": "container",
    16.             "tags": ["blahtag"],
    17.             "images": {
    18.                 "horizontal": {
    19.                     "md": "http://foo.bar/hm.png",
    20.                     "sm": "http://foo.bar/hs/png"
    21.                 },
    22.                 "vert": {
    23.                     "md": "http://foo.bar/vm.png",
    24.                     "sm": "http://foo.bar/vs/png"
    25.                 }
    26.             }
    27.         },
    28.         {
    29.             "description": "Description2",
    30.             "key": "subcat2",
    31.             "name": "SubCat 2",
    32.             "type": "container",
    33.             "tags": ["blahtag"],
    34.             "images": {
    35.                 "horizontal": {
    36.                     "md": "http://foo.bar/hm.png",
    37.                     "sm": "http://foo.bar/hs/png"
    38.                 },
    39.                 "vert": {
    40.                     "md": "http://foo.bar/vm.png",
    41.                     "sm": "http://foo.bar/vs/png"
    42.                 }
    43.             }
    44.         }]
    45.     }
    46. }
    The video list is formated very similar, but I think once I get the sub categories I can get the video list.
    Also if there is subcategories of sub categories, is that possible?
    ie;
    Code (Text):
    1.  
    2. Audio
    3.     80s
    4.        <song list>
    5.     70s
    6.        <songlist>
    7. Video
    8.     Action
    9.        <movie list>
    10.     Comedy
    11.        <movie list>
    12. ...



     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
    I know my post might not be that useful. I was just wondering why you don't implement your side by using an own SiteUtil? It offers you an json parser which would be much easier.
    I work right now with onlineVideos for MP2Ext, that's why I am a bit familiar with that.

    But I am really bad when it comes to RegEx :ROFLMAO:
     
  4. howudodat

    howudodat Portal Pro

    Joined:
    February 20, 2007
    Messages:
    75
    Likes Received:
    2
    Ratings:
    +2 / 0
    Home Country:
    United States of America United States of America
    I'd be glad to give SiteUtil a try...is there any documentation on using it to parse JSON? I cant find any...I searched the forums earlier and couldn't see anything there either :(
     
  5. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
    It is using the Newtonsoft Json parser.
    I do it like this:
    Code (Text):
    1. WebSortField webSortField = (WebSortField)JsonConvert.DeserializeObject(sort, typeof(WebSortField));
    Or look here:
    http://www.newtonsoft.com/json/help/html/deserializeobject.htm

    Hope it helps ;)
     
  6. howudodat

    howudodat Portal Pro

    Joined:
    February 20, 2007
    Messages:
    75
    Likes Received:
    2
    Ratings:
    +2 / 0
    Home Country:
    United States of America United States of America
    OK, but how is this used by onlinevideos. I don't see a way to do programming. I only see a way to do regex. I must be missing Something near step 1 :(
     
  7. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
  8. howudodat

    howudodat Portal Pro

    Joined:
    February 20, 2007
    Messages:
    75
    Likes Received:
    2
    Ratings:
    +2 / 0
    Home Country:
    United States of America United States of America
    ok, so do I have to build all off onlinevideos and my site becomes integrated to the core dll, or is this a plugin to the plugin? I'll have to dl vs c#. I dont have a devel environment set up on windows. I actually an a programmer for 30+ years, but all my current projects are on linux.
     
  9. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
    It will become a plugin. The Plugins in OnlineVideo are called SiteUtils. Basically plugins for a plugin.
    They are located in: C:\Users\All Users\Team MediaPortal\MP2-Client\OnlineVideos\SiteUtils
    Or if you are using MP1: C:\Users\All Users\Team MediaPortal\Mediaportal\OnlineVideos\SiteUtils
     
  10. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
    And I think the naming is important, but I could be wrong: OnlineVideos.Sites.offbyone.dll
    OnlineVideos.Sites.AUTHOR.dll
     
  11. howudodat

    howudodat Portal Pro

    Joined:
    February 20, 2007
    Messages:
    75
    Likes Received:
    2
    Ratings:
    +2 / 0
    Home Country:
    United States of America United States of America
    ok, I have the project downloaded, and setup and I see that the sites just basically become plugins to the plugin. Is there any kind of documentation on how to proceed? What interfaces need implemented? etc. Or is it just study code and hack?
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!