downforacross / downloadacross

chrome extension for downloading crosswords from various sources
4 stars 4 forks source link

Guardian Loader #9

Closed multimeric closed 4 years ago

multimeric commented 4 years ago

Hi, I'm interested in adding a loader for the Guardian newspaper crosswords. Is this something you'd accept a PR for?

stevenhao commented 4 years ago

Yeah, go ahead!

multimeric commented 4 years ago

Can you explain what it is that loaders do exactly? Am I outputting a .puz binary file, or is there a way to output a JavaScript representation of the puzzle which will then be converted to a .puz?

stevenhao commented 4 years ago

Great question! I'll try to add some documentation on what shape the loaders should produce, but you are right that it's a js object representation. The object gets encoded as puz file in a separate step, you don't need to worry about the puz format if you're just adding a new loader.

In the meantime, there's some console logs in https://github.com/downforacross/downloadacross/blob/master/src/popup.js#L198:L198; here's the output of a LA times loader; all the other ones look similar. This is the output as json:

{
  "meta": {
    "description": "",
    "title": "LA Times, Thu, Apr 9, 2020",
    "notes": "",
    "author": "Bruce Haight / Ed. Rich Norris",
    "copyright": "© 2020 Tribune Content Agency, LLC"
  },
  "grid": [
    [ "O", "B", "E", "Y", ".", "E", "D", "S", "E", "L", ".", "T", "E", "T", "E" ],
    [ "L", "A", "C", "E", ".", "T", "O", "T", "E", "S", ".", "V", "L", "O", "G" ],
    [ "G", "R", "O", "W", "I", "N", "G", "O", "L", "D", ".", "L", "U", "N", "G" ],
    [ "A", "O", "L", ".", "N", "A", "I", "L", ".", ".", "H", "A", "D", "T", "O" ],
    [ ".", "F", "O", "N", "T", ".", "T", "I", "E", "S", "O", "N", "E", "O", "N" ],
    [ "O", "S", "G", "O", "O", "D", ".", ".", "T", "H", "U", "D", ".", ".", "." ],
    [ "S", "O", "I", "L", ".", "R", "A", "S", "H", "E", "S", ".", "A", "H", "A" ],
    [ "H", "A", "S", "A", "N", "I", "N", "T", "E", "R", "E", "S", "T", "I", "N" ],
    [ "A", "P", "T", ".", "A", "V", "I", "D", "L", "Y", ".", "L", "O", "T", "T" ],
    [ ".", ".", ".", "A", "V", "E", "S", ".", ".", "L", "L", "A", "M", "A", "S" ],
    [ "F", "O", "R", "S", "A", "L", "E", "A", "D", ".", "I", "M", "I", "N", "." ],
    [ "S", "K", "O", "A", "L", ".", ".", "B", "O", "Z", "O", ".", "C", "D", "C" ],
    [ "T", "A", "B", "S", ".", "E", "L", "E", "M", "E", "N", "T", "A", "R", "Y" ],
    [ "O", "P", "I", "E", ".", "A", "S", "T", "E", "R", ".", "A", "G", "U", "A" ],
    [ "P", "I", "N", "T", ".", "R", "U", "S", "S", "O", ".", "P", "E", "N", "N" ]
  ],
  "clues": {
    "across": [ null, "Mind", null, null, null, "Old lemon", null, null, null, null, "What's under a beret", null, null, null, "Oxford tightener", "Pledge drive gifts", "YouTube journal", "Getting on in years", null, "Lobed organ", "Web pioneer", "Polish place", "Couldn't help it", "Document feature with size options", null, "Gets plastered", null, null, "\"See You on the Radio\" essayist Charles", null, "Dull sound", "Transplanting need", "Some allergy symptoms", null, null, "\"So that's what's going on here!\"", null, null, "Owns part of", null, null, "Well-suited", "With enthusiasm", "Ronnie in the Pro Football Hall of Fame", "Rtes. often numbered", "Pack animals", null, "Classified item", null, null, null, null, "\"Let's do it!\"", "European toast", "Chucklehead", null, "Atlanta-based health agcy.", null, "Document settings", "Holmes' comment about the ends of the four other longest Across answers?", null, null, "\"Return to Mayberry\" grown-up", "Frost-resistant flower", "Golfo contents", "Ice cream buy", "__-Japanese War", "One of the Ivies" ],
    "down": [ null, "\"Quantum of Solace\" actress Kurylenko", "Cake on a dish", "EPA scientist", "Longbow wood", "Italian smoker", "Slack off", "Skyy shelfmate, familiarly", "__ sauce: sushi condiment", "Trippy '60s drug", "Cable network with classic sitcoms", "Get past", "Jay Silverheels role", "Prod", null, null, null, null, "\"What have I gotten myself __?\"", null, null, null, "__ cat", null, "Mardi Gras acronym", null, "Musical star Merman", "Grammy winner Crow", "Hazmat monitor", "Rot", null, null, null, "Sambuca flavoring", "Avg.", "Period spawned by the Manhattan Project", "Baseball strategy for a contact hitter", "Little marchers", null, "Maritime", "Bridge feat", null, null, null, "How china is sold", null, "Fuzzy film coward", "Shooter's setting", "Congo critter with striped legs", "Dick Grayson's alter ego", "Does some fencing, maybe", "Stadium toppers", null, null, null, "Terrible test score", null, "Ink cartridge color", null, "Corn serving", "2020 NCAA FBS champs", "Touch-screen touch" ]
  },
  "circles": [],
  "filename": "lat200409thu.puz",
  "rating": {
    "img_str": "<img src='/star35.jpg' class='inline' style='height:13px; margin-top:0px; margin-bottom:0px;' title='5*: 3 | 4.5*: 4 | 4*: 4 | 3.5*: 1 | 3*: 2 | 2.5*: 2 | 2*: 1 | 1.5*: 1 | 1*: 1'> ",
    "round_avg": "3.58",
    "count": 19,
    "rated": 0,
    "link": "http://crosswordfiend.com/2020/04/08/thursday-april-9-2020/#la"
  }
}

And here is a screenshot of the original puzzle from https://www.latimes.com/games/daily-crossword image

multimeric commented 4 years ago

Ah, that's quite helpful, thank you. It shouldn't be too hard to wrangle data into that format. Incidentally that's quite similar to the XPF JSON format. Is that intentional?

So am I right in my understanding that the pipeline is: website HTML → internal JSON → .puz binary? And it provides the .puz files as downloads right, so it's not tied to downloadacross? I'm interested in using this for another downstream application as well.

Incidentally, would you object to me restructuring the repo with some webpack or something? I find it a tad hard to navigate without imports/exports.

stevenhao commented 4 years ago

Yeah, the pipeline you described is correct, yeah. Feel free to use your puz files however you'd like.

I think I only discovered XPF after writing downloadacross, so any similarity is probably coincidental.

No objections to webpack!

stevenhao commented 4 years ago

Also added Guardian Cryptics (they're pretty good too)! https://github.com/downforacross/downloadacross/commit/38039a44ebeea75a4581b815cf65ecfdb3b1b447

multimeric commented 4 years ago

Ah nice, I had wondered why I saw a Guardian Cryptic on downforacross.