jpd236 / kotwords

Collection of crossword puzzle file format converters and other utilities, written in Kotlin.
Apache License 2.0
25 stars 6 forks source link

Thank you #36

Closed vcifello closed 1 year ago

vcifello commented 1 year ago

Hi Jeff,

I just wanted to say thank you for Crossword Scraper and Kotwords. Really incredible work!

I became interested since the removal of .puz from the NYT, but just decided to dig in to the details. This library is truly amazing.

I have been able to follow the processing of the JSON returned from their API json->NYTApiJson->NYTJson->NYT constructor -> Puzzleable() Puzzle that AcrossLite.asAcrossLiteBinary can save as .puz Is that correct?

So, your Puzzle object must be the same as the native .puz object. Or am I not understanding this.

I hope this is not too much of an imposition. Thanks in advance, Vin.

jpd236 commented 1 year ago

Thanks for the kind words!

The Puzzle class is meant to be a generic, formatless representation of a puzzle. You can think of it as supporting the superset of features supported by all of the interactive formats (puz, jpz, ipuz) that Kotwords supports. From there, each format's class has a way to convert from a Puzzle to its native representation. The AcrossLite conversion logic is indeed in AcrossLite.asAcrossLiteBinary here which takes a Puzzle as input and returns the binary AcrossLite data. There are a few Kotlin syntactic tricks that may make it harder to follow if you're not as familiar, but that's where things end up.

So Puzzle and the native .puz format aren't quite the same; the conversion strips out some of the unsupported features of the .puz format while maintaining as much of the important pieces of the puzzle as possible. In contrast, Puzzle -> JPZ or IPUZ is a much more faithful conversion.

Does that answer your question?

vcifello commented 1 year ago

Yes! I was definitely missing the final conversion logic because I don't really understand the syntax. This last part is starting to make sense now that I put a puz file into a hex editor.

I was hoping to somehow automate the conversion to avoid manually downloading and emailing the puzzle file for upload in our iPads.

I managed to figure out how to sign in to the NYT(nightmare). I am converting the Postman calls into a Python script. I am able to parse the NYT json response into the AcrossLite text format. Which appears to require AcrossLite to convert to puz

That's when I realized that you were the only one who really figured out how to go from json to puz.

I'll keep plugging along. Thanks again!

jpd236 commented 1 year ago

Gotcha.

For what it's worth, there's another implementation in Python at https://github.com/thisisparker/xword-dl which does the same thing - scrape .puz files from the NYT. It uses https://github.com/alexdej/puzpy to handle the puz conversion.