jlkatz / OCTGN.OCTGNDeckConverter

A comprehensive OCTGN deck converter for OCTGN 3 which can convert several formats, websites, and plain text into the OCTGN 3 format.
http://octgngames.com/deckconverter/
7 stars 9 forks source link

Importing from CardGameDB no longer works (LOTR) #13

Open GeckoTH opened 9 years ago

GeckoTH commented 9 years ago

CardGameDB has recently undergone some changes and have implemented a new deckbuilder, as well as modified the layout of the submitted deck pages. Unfortunately, the URL to these deck pages no longer work in the Deck Converter. For example, linking to "http://www.cardgamedb.com/index.php/thelordoftherings/the-lord-of-the-rings-decks/_/lord-of-the-rings-submitted-decks/dunland-hobbit-r10" returns the following error:

An error occurred while trying to convert the deck. Please try again.

Details: System.NullReferenceException: Object reference not set to an instance of an object. at System.Object.GetType() at OCTGNDeckConverter.Model.HtmlAgilityPackWrapper.HtmlNode_InvokeMethod_SelectSingleNode(Object htmlNodeInstance, String xpath) at OCTGNDeckConverter.Model.ConvertEngine.ConvertURL_cardgamedb_com_LoTR(String url, IEnumerable`1 deckSectionNames) at OCTGNDeckConverter.Model.Converter.Convert()

jlkatz commented 9 years ago

Thanks for submitting this, I was able to replicate the issue. Looks like I need to update how the converter scrapes the webpage.

jlkatz commented 9 years ago

I checked in the fix for this, it'll be in the next release.

GeckoTH commented 9 years ago

Thanks for the quick update! i wanted to draw your attention to another 'bug' with CardGameDB import, though this has more to do with how that site handles its decks rather than with your plugin.

For decks that have been officially "submitted", your Deck Converter v3.3.0 works flawlessly. Such as with this page: http://www.cardgamedb.com/index.php/thelordoftherings/the-lord-of-the-rings-decks/_/lord-of-the-rings-submitted-decks/mono-spirit-r25 (I also noticed that you were able to normalize the search strings to solve the 'accent' problem -- Nicely done!)

However, CardGameDB also lets you simply save your own personal decks to your account, without officially 'submitting' them. This is great if you like to keep a personal library of decks that you can constantly update/tweak to your liking. The deckbuilder can then generate a link to your saved deck to share with others, like this example: http://www.cardgamedb.com/index.php/thelordoftherings/the-lord-of-the-rings-deck-share?p=4226&deck=lotrdeck_53bf7c75f0309

While these two example pages look similar on the surface, they are clearly handled/generated differently, and the 'personal' deck page does not load into your Deck Converter. It generates the following error:


An error occurred while trying to convert the deck. Please try again.

Details: System.ArgumentOutOfRangeException: StartIndex cannot be less than zero. Parameter name: startIndex at System.String.Substring(Int32 startIndex, Int32 length) at OCTGNDeckConverter.Model.ConvertEngine.ConvertURL_cardgamedb_com_LoTR(String url, IEnumerable`1 deckSectionNames) at OCTGNDeckConverter.Model.Converter.Convert()


I'm not sure if you're able to handle both types of pages or not, but I figured I'd at least bring it to your attention. Thanks again!

jlkatz commented 9 years ago

Thanks for the feedback! From your notes I see that cardgamedb has two implementations of the deck viewing webpage. I did some experiments and found out how to extract the deck data in json format. It was a fun exercise, I learned how to submit POST forms in C#. This will make it's way into the plugin eventually.

GeckoTH commented 9 years ago

Very cool! Excited to see what you come up with.

jlkatz commented 9 years ago

It's working for both types of decks now, although I only tested it with the two urls you listed. Can you try out this development version for me?

https://www.mediafire.com/?6zgufxxam3t6irc

GeckoTH commented 9 years ago

Looks outstanding to me! I've encountered no errors with the 'new' submitted deck pages, or with my personal decks. The Text from Clipboard feature also works great now, with or without accented names.

I've sent this to one other friend of mine who uses CardGameDB to manage a bunch of LOTR decks. He should get back to me hopefully tomorrow to confirm if it works for him as well. Thanks again for your fast support!