Welcome, Guest
A place to meet other Developers

TOPIC: OData for ComicRack

OData for ComicRack 5 years 7 months ago #20929

  • Neep
  • Neep's Avatar
  • Offline
  • Senior Boarder
  • Posts: 62
  • Thank you received: 7
  • Karma: 10
Latest version is now always here:
bitbucket.org/adamhathcock/comicrackodata/downloads


I'm hoping other developers with find this stuff useful. I think I've seen people mention how to get their catalog information as a web page to be used on any kind of device. I want to keep the application itself at the center because it's way better at organizing than anything I want to write. For example, I want to have an iPad application (or anything really) that points a URL to my own machine where ComicRack is running to look at comics.

What I've done is just made a simple OData provider for ComicRack that is hosted as a plugin inside the ComicRack application to use it's API as a datasource. I did this just using WCF Data Services from microsoft.

What OData is: www.odata.org/
WCF Data Services: msdn.microsoft.com/en-us/library/cc668792.aspx
WCF Data Services blog: blogs.msdn.com/b/astoriateam/

The attached plugin zip (I haven't bothered making it a real nice plugin yet :) should able to be installed into ComicRack. A blank button should appear and a little dialog to start or stop the service will be presented. You can specify a port to bind to on localhost. !!You have to curry run ComicRack with admin privileges because .NET wants them to able to bind to a port!! Once it starts, you should be able to browse to it (e.g. http://localhost:8080/Comics) It's always /Comics.

In IE, you'll see an atom feed. Chrome will render this as XML like:
<?xml version="1.0" encoding="iso-8859-1"?><feed xml:base="http://localhost:8080/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>http://localhost:8080/Comics</id><title type="text">Comics</title><updated>2012-02-19T17:21:42Z</updated><link rel="self" title="Comics" href="Comics" /><entry><id>http://localhost:8080/Comics('2aed8ceb-0a41-43da-bfdf-1ab16ef36032')</id><category term="ComicRackODataService.Comic" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" title="Comic" href="Comics('2aed8ceb-0a41-43da-bfdf-1ab16ef36032')" /><title type="text">The Black Ring, Part Three; A Look at Things to Come in... Superboy</title><summary type="text">Action Comics</summary><updated>2012-02-19T17:21:42Z</updated><author><name /></author><link rel="edit-media" title="Comic" href="Comics('2aed8ceb-0a41-43da-bfdf-1ab16ef36032')/$value" /><content type="application/zip" src="Comics('2aed8ceb-0a41-43da-bfdf-1ab16ef36032')/$value" /><m:properties><d:Id>2aed8ceb-0a41-43da-bfdf-1ab16ef36032</d:Id><d:Description>Action Comics</d:Description></m:properties></entry><entry><id>http://localhost:8080/Comics('7795a343-76a6-4185-add1-9b8b704135cc')</id><category term="ComicRackODataService.Comic" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" title="Comic" href="Comics('7795a343-76a6-4185-add1-9b8b704135cc')" /><title type="text">The Black Ring, Part Four; Jimmy Olsen's Big Week, Day One</title><summary type="text">Action Comics</summary><updated>2012-02-19T17:21:42Z</updated><author><name /></author>

A lot of stuff in there. This is intended to be consumed by anything that understands OData. To test it for a single comic, you can go to one of the URLs (e.g.
http://localhost:8080/Comics('7795a343-76a6-4185-add1-9b8b704135cc')
)

To stream the actual comic file, you can go to:
http://localhost:8080/Comics('7795a343-76a6-4185-add1-9b8b704135cc')/$value

This always gives you a zip file in Chrome because I made the content type be application/zip but it's really whatever format ComicRack has it as.

Updated with pages and thumbnails.

For this comic:
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')

This is the cover metadata:
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')/Cover
and this is the image:
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')/Cover/$value
cover thumbnail:
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')/CoverThumbnail
cover thumbnail image:
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')/CoverThumbnail/$value

There are also page and thumbnail collections that the comic entity will link to:
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')/Pages
http://localhost:8080/Comics('d7639ef4-aa1d-4a76-83bf-f65db3e1e768')/Thumbnails

Also, be sure to look at the OData URI Protocol if you're hitting the URLs directly rather than using the WCF API:
www.odata.org/developers/protocols/uri-conventions

You may want to do things like limit to the first 100 results:
http://localhost:8080/Comics?$top=100

Added Search (title and/or series) and JSON format.

Search for any series that contains "batman" as json:
http://localhost:8080/Search?series='batman'&$format=json

Search for any series with "batman" and title has "r.i.p."
http://localhost:8080/Search?series='batman'&title='r.i.p.'

let me know things go and ideas for improvement

Latest version is now always here:
bitbucket.org/adamhathcock/comicrackodata/downloads
Last Edit: 5 years 7 months ago by Neep.
The administrator has disabled public write access.
The following user(s) said Thank You: ahroun

Re: OData for ComicRack 5 years 7 months ago #20930

  • Neep
  • Neep's Avatar
  • Offline
  • Senior Boarder
  • Posts: 62
  • Thank you received: 7
  • Karma: 10
Oops, can't attach the script zip.

Download from here: hathcock.co.uk/ComicRackODataService.zip
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20931

  • perezmu
  • perezmu's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 1112
  • Thank you received: 64
  • Karma: 51
Neep wrote:
Oops, can't attach the script zip.

Download from here: hathcock.co.uk/ComicRackODataService.zip

Wow! This looks promising!!!!
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20950

  • perezmu
  • perezmu's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 1112
  • Thank you received: 64
  • Karma: 51
No luck... exception thrown (win 7) :(
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20951

  • Neep
  • Neep's Avatar
  • Offline
  • Senior Boarder
  • Posts: 62
  • Thank you received: 7
  • Karma: 10
perezmu wrote:
No luck... exception thrown (win 7) :(

Dang.

I've updated the link to actually throw up a MessageBox with the exception in it. If you don't mind trying to run it again, could you screenshot the exception? I'm guessing it's a missing DLL or something. I'm not 100% on what I need to include in the zip from the distribution. Thanks!

I'm also looking for ideas on what to do with this stuff as I'm too cheap to buy an Apple Dev License and Monotouch.
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20952

  • perezmu
  • perezmu's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 1112
  • Thank you received: 64
  • Karma: 51
Neep wrote:
I've updated the link to actually throw up a MessageBox with the exception in it. If you don't mind trying to run it again, could you screenshot the exception? I'm guessing it's a missing DLL or something. I'm not 100% on what I need to include in the zip from the distribution. Thanks!

Hi. I could not get to your message box with the exception in it, it seems to fail with a "generic" fail before reaching that point. No screenshot, since it does not provide any info, but running the script in CR debugging mode yields this:
Calling 'ComicRackODataService'...
Compilation of 'C:\Users\apm\AppData\Roaming\cYo\ComicRack\Scripts\Comic Rack OData Service\Program.py'
Could not load file or assembly 'ComicRack.Plugins, Version=1.0.4418.37270, Culture=neutral, PublicKeyToken=b3ca110c99b4b731' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I hope this helps!
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20956

  • Neep
  • Neep's Avatar
  • Offline
  • Senior Boarder
  • Posts: 62
  • Thank you received: 7
  • Karma: 10
perezmu wrote:
Neep wrote:
I've updated the link to actually throw up a MessageBox with the exception in it. If you don't mind trying to run it again, could you screenshot the exception? I'm guessing it's a missing DLL or something. I'm not 100% on what I need to include in the zip from the distribution. Thanks!

Hi. I could not get to your message box with the exception in it, it seems to fail with a "generic" fail before reaching that point. No screenshot, since it does not provide any info, but running the script in CR debugging mode yields this:
Calling 'ComicRackODataService'...
Compilation of 'C:\Users\apm\AppData\Roaming\cYo\ComicRack\Scripts\Comic Rack OData Service\Program.py'
Could not load file or assembly 'ComicRack.Plugins, Version=1.0.4418.37270, Culture=neutral, PublicKeyToken=b3ca110c99b4b731' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I hope this helps!

That's very useful. Thanks.

I updated the zip again. It should be not using strong references now. If that error happens again, let me know what version of ComicRack you're using. I'm on 0.9.152 64 bit. I guess the Plugins DLL is a different version for me than for you. I should be building against non-specific versions now.

I just added support for doing Series since it's more friendly for the eyes:

examples:
http://localhost:8080/Series
http://localhost:8080/Series('Asterios%20Polyp')

I really appreciate your help to get this work on a machine other than mine :)
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20961

  • perezmu
  • perezmu's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 1112
  • Thank you received: 64
  • Karma: 51
Hi there.

First try, no luck. Same error message. Checked CR version and upgraded to the same as you.
Second try, better luck but no go!: I get the message box requesting server port, but after clicking "Start", it seems that nothing happens (the 'Stop' button is still grayed out)... I try to navigate to the given port on localhost, and no luck. CR becomes frozen and I get an error log from comicrack itself (not in the console, but in the dialog that prompts me to close CR because it has crashed).

The log is at:

pastebin.com/qBHxM3Dn

I am using 32 bits. Might this be the difference? I have a 64 machine, but cannot acces it for a few days. Sorry.

Cheers.
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20962

  • Neep
  • Neep's Avatar
  • Offline
  • Senior Boarder
  • Posts: 62
  • Thank you received: 7
  • Karma: 10
perezmu wrote:
Hi there.

First try, no luck. Same error message. Checked CR version and upgraded to the same as you.
Second try, better luck but no go!: I get the message box requesting server port, but after clicking "Start", it seems that nothing happens (the 'Stop' button is still grayed out)... I try to navigate to the given port on localhost, and no luck. CR becomes frozen and I get an error log from comicrack itself (not in the console, but in the dialog that prompts me to close CR because it has crashed).

The log is at:

pastebin.com/qBHxM3Dn

I am using 32 bits. Might this be the difference? I have a 64 machine, but cannot acces it for a few days. Sorry.

Cheers.

It says it can't register the port which probably means you're not running CR as admin. Are you sure you're running as admin? sorry, I should have asked about it before. Easiest way is to change your CR shortcut to Run As Administrator under the Compatibility tab.

I need to see if I can check for admin privileges with the plugin.

Thanks again for the testing you're doing for me :)
The administrator has disabled public write access.

Re: OData for ComicRack 5 years 7 months ago #20967

  • Neep
  • Neep's Avatar
  • Offline
  • Senior Boarder
  • Posts: 62
  • Thank you received: 7
  • Karma: 10
Okay, it now tests for administrator privileges.

hathcock.co.uk/ComicRackODataService.zip

Thanks again!
The administrator has disabled public write access.
Time to create page: 0.259 seconds

Who's Online

We have 255 guests and one member online