Comments (13)
Good work @BlitzKraft
from xkcd-dl.
Thanks a lot for your time. Will fix these issues as soon as possible.
from xkcd-dl.
I have attempted to solve requests 1 and 2 (partially, images are downloaded to working dir) in my pull request #9.
from xkcd-dl.
Now that #9 has been merged most of the changes requested in sections 1 and 2 are implemented.
I'm not up for tackling section 3 or the parameter change in section 2, that'll have to be up to either @prodicus or @bradenbest.
from xkcd-dl.
Update: Both enhancements, 1 and 2 were added by @Kickball in pull request #9 .
Nicely done @Kickball .
from xkcd-dl.
Enhancement 3 can be obtained by merely adding this to line 106:
img_tooltip = img_tag.get('title')
however writing that information to the json file will prove harder.
from xkcd-dl.
Are you referring to the special character's issue when writing to the file @Kickball ?
from xkcd-dl.
@Kickball I don't see why you can't just write it to a text file called title.txt
. In fact, I'll get on that
from xkcd-dl.
So I found the linkaround 106, and changed a little bit:
for data in image_page_content_soup.find_all("div", {"id": "comic"}):
for img_tag in data.find_all('img'):
img_link = img_tag.get('src')
img_tooltip = img_tag.get('title')
# here
complete_img_url = "http:{url}".format(url=img_link)
img_tooltip_file_name = "{current_directory}/xkcd_archive/{name}/title.txt".format(current_directory=WORKING_DIRECTORY, name=xkcd_number)
# here
file_name = "{description}.jpg".format(description=new_description)
urllib.request.urlretrieve(complete_img_url, file_name)
write_tooltip(img_tooltip, img_tooltip_file_name)
# here
And added the write_tooltip
function:
def write_tooltip(tooltip, file_name):
f = open(file_name, "w")
f.write(tooltip)
print("Debug: I should be writing \"%s\" to file '%s'" % ("Hello world", file_name))
f.close()
Well, that's what it looked like just before I found out why it wasn't writing the file. Yeah, turns out the function isn't even being called.
See, I thought I was editing the function that downloads an xkcd page and saves it to its directory
. Turns out it's a function that downloads an xkcd page and saves it to its directory
, out of like 3 or 4 other ones.
I was gonna let the 80-line function slide and just say you needed to refactor your code some, but this is ridiculous. This is a classic case of data duplication
. Why isn't the downloading abstracted to a single function that takes an argument (the "xkcd_number"), and downloads it? Then you can use that with all of the other xkcd-downloading functions. For example, download_all()
loops through all the xkcd_numbers
it knows about and calls download_page()
with each of them, whereas download_latest()
does whatever it does and calls download_page()
for each result, and the one that acts on --download=<number>
just calls download_page()
with the user's input.
Your code needs some cleanup. And I don't even need proof, because the proof is in the code comments: their existence proves that the code is messy.
I'm gonna post that as a separate issue, and when that issue is resolved, I'll make another attempt at implementing enhancement 3
from xkcd-dl.
And just to be absolutely clear, what, in particular, I am expecting with enhancement 3
is that when you download an image, in addition to <description>.png
and description.txt
, there should be a file title.txt
, that contains the title text of an image, e.g. for #1000
, the contents of title.txt
should be Thank you for making me feel less alone.
from xkcd-dl.
@bradenbest Title text download is now possible and is covered by f2bdb48
The hover text is saved in the description.txt file. I personally don't like having too many files.
from xkcd-dl.
@prodicus Everything in this issue has been addressed. Please close this.
from xkcd-dl.
PR #23 and the previous PR's implement all the above suggestions.
However if anything is missed, feel free to comment on this issue and I will open it again
from xkcd-dl.
Related Issues (16)
- prompt's `--update-db` when run in any other directory than the `HOME` directory HOT 1
- Needs cleanup HOT 7
- Example for --path argument not there in README
- Alt text not getting downloaded
- Sanitizing titles in the comic HOT 1
- Opening on the comic on the command line, options? HOT 12
- Ability to open xkcd's from the terminal HOT 1
- Version 0.1.0 - Unknown references to version, VERSION and __version__ HOT 2
- urllib.request issue HOT 4
- XKCD 961 Eternal Flame animated gif HOT 10
- Adding tests to xkcd-dl HOT 4
- 404 in the xkcd_dl website HOT 1
- Crashes randomly
- Installed, but after that nothing works.
- Does not work out of the box, if at all HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xkcd-dl.