Quote:
Originally Posted by iatheia
It's not that it isn't allowed, it is just it's too complicated to do - the site has really overdid itself on the legal warnings, and just a tad bit too ugly to attempt. Plus it appears that they are undergoing a rewrite. Not really ideal for the first adapter, but if you want to try it - go ahead.
The way you going around is is a tad bit ineffective, in my opinion. You will learn very little at staring at the result of someone else's complicated code. The best way to learn how to code is by doing So take some adapter (adapter_castlefansorg.py is as good of a way to start as any given its documentation) and start playing around with it - modifying a part there, a part here to fit certain purposes. Look at the html code of that example website, too, to see why it was coded like that. That's how I've learned, at least. AFF is not efiction of course, which makes a matter tad bit complicated, but at least it will show you what are all the components that go into it.
And if upon the compiling you generate an error, and upon staring at it for a couple of minutes (and checking the code at the line specified in the error) you cannot figure the solution - try googling it. If that still doesn't work - feel free to ask us, we'll help to the best of our abilities.
|
I've been able to create an AFF adapter before for FLAG (PHP). It's possible to ignore the redirect to the warning page (at least using curl by setting CURLOPT_FOLLOWLOCATION to false). I think I'll try to do the proper thing with the birthday/signature stuff (as a user-configurable option) but if that fails, I can try to find the python equivalent to the above php+curl option.
I've been viewing a couple of FFDL adapters and dokuga.com seems to be the closest match. As for being ineffective, well it works for me. Viewing code examples and seeing what they do is generally how I learn a language. Needless to say, Calibre's code is too complicated for me but the FFDL code doesn't appear to be too daunting. This is why I'd prefer to be able to see step by step output.
Quote:
Originally Posted by iatheia
And while I'm at it, here is a helpful bit of advise before you do anything. Python fundamentally depends on the proper formatting of the code. Other languages may allow everything to be flushed to the edge, but python would be very confused and yell at you if that were the case. So do keep the same formatting as the code you're modifying - four spaces (not tabs!) per indent. This is something that gave me hell to figure out when I've just started.
|
Thanks. I'm already familiar with Python indenting rules (from writing custom Calibre template functions, etc) and Notepad++ makes this very simple.
Quote:
Originally Posted by JimmXinu
@ilovejedd - That would be a bit of a hefty feature to add just for playing with.
|
I figured that would be the case after I looked at the code for some of the site adapters (hadn't checked them before I made the request). To implement it, each site adapter would need to be edited. On the upside, it appears I can easily add the option to whatever site adapter I'm working with and comment it out later.
Quote:
Originally Posted by JimmXinu
It's much easier to try different things and work on the code in command line than it is in the plugin. In command line, every edit you save is used immediately the next time you run it. In plugin, you have to create the updated plugin zip, install it and restart calibre for every single change.
|
No need to restart but yeah, need to go through the hassle of creating the updated plugin and then installing it to calibre.
Quote:
Originally Posted by JimmXinu
There's a command line interface(CLI) version of FFDL available. If you don't want to install Python separately, after getting and unzipping the CLI version you can use "calibre-debug -e download.py" to run it using calibre's built-in python.
When debugging plugins, when I want to see what the HTML from the site looks like before any processing, I find the fetch call (typically "data = self._fetchUrl(url)") and then add a "print(data)" call. Consider that your first step in learning python.
Then run the CLI downloader and redirect it's output to a file. Something like this:
Code:
c:\Python27\python.exe downloader.py "http://test1.com?sid=4" > output
Editing downloader.py and changing where it says
"logging.basicConfig(level=logging.INFO,..." to
"logging.basicConfig(level=logging.DEBUG,..." is also useful.
When testing FFDL output or settings, you can use the dummy site test1.com with story URLs like test1.com?sid=123 That will generate output, but not waste time and bandwidth going out to a real site.
|
Thanks for the tips! Another question I'd like to ask, short of editing the lmhosts file or creating a proxy, is there a way I can get FFDL to read a previously download copy of a webpage instead of always having to retrieve it from the internet? This would be useful when working offline on my laptop in places without internet access.
Thanks!