-
Notifications
You must be signed in to change notification settings - Fork 18
Needs cleanup #10
Comments
Hey @bradenbest I appreciate it that you are taking your time to point out the issues in the code. And I whole hearted-ly agree that there is redundancy in the code(I mean a lot!). I mean I just hacked it up under one night and this was barely working. These issues make it hard to maintain the code and I agree to it. However a lot of things like When I wrote the initial release for this, I wasn't aware of the fact that xkcd had an API to it. So if anybody were to get the latest issue of the xkcd and the relevant information would be provided by requesting the url : http://xkcd.com/info.0.json It would return back something like this, {
"month": "1",
"num": 1632,
"link": "",
"year": "2016",
"news": "",
"safe_title": "Palindrome",
"transcript": "",
"alt": "I hope that somewhere in the world, \"Panamax\" is the last option on a \"size\" drop-down menu on a sex toy site.",
"img": "http:\/\/imgs.xkcd.com\/comics\/palindrome.png",
"title": "Palindrome",
"day": "20"
} And similarly for comic number 1 we can request http://xkcd.com/1/info.0.json. And it will return back {
"month": "1",
"num": 1,
"link": "",
"year": "2006",
"news": "",
"safe_title": "Barrel - Part 1",
"transcript": "[[A boy sits in a barrel which is floating in an ocean.]]\nBoy: I wonder where I'll float next?\n[[The barrel drifts into the distance. Nothing else can be seen.]]\n{{Alt: Don't we all.}}",
"alt": "Don't we all.",
"img": "http:\/\/imgs.xkcd.com\/comics\/barrel_cropped_(1).jpg",
"title": "Barrel - Part 1",
"day": "1"
} So simply using So I can see a massive rewrite coming up. Any other suggestions would be more than welcome 😄 |
@prodicus I can try, but gosh, I haven't programmed in python in a while. The last big one I did was an html scraper called ngdl, that worked by grabbing the first url that matched
You know, the kind of silly/clever things you do when hacking things together. Couldn't get cookies to work though. I was hoping I could spoof it, but I need cookiejar, which looks irritating to use. And before that was a personal bookkeeping project where I used JSON to save data. I like JSON. |
Also, what's |
And if you're going to overhaul it, well, here's what I would do instead of simple refactoring:
This will keep major (incompatible) versions separate and will allow you to gracefully deprecate the first version while still allowing people to fetch it if they want. That's what I did with one of my projects. |
@bradenbest I am gonna see if I would be able to start it soon. As for Now don't be so modest @bradenbest . Your projects look cool to me. 😄 . Meanwhile, you can start working on it if you wish. |
@prodicus So that's what it's for. You should definitely take advantage of it for the next update. As in, split the source between files that handle a task, and then have Whoa, word salad. Here, I made a test implementation:
main.py:
say.py:
get.py:
shell:
|
looks like somebody is really excited eh! 💃 Good one though. 😄 |
As mentioned in #6, I tried to step into the code and immediately noticed 3 things:
The code needs some serious refactoring.
My suggestions are to:
download_page(xkcd_number)
, like the example referenced in the last comment in Suggestions #6)The text was updated successfully, but these errors were encountered: