View Single Post
Old 09-07-2013, 12:43 PM   #1802
Sefiriot
Bujavid tekikin
Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.Sefiriot writes the songs that make the whole world sing.
 
Sefiriot's Avatar
 
Posts: 139
Karma: 40366
Join Date: Aug 2013
Location: Malaysia
Device: LG G3 D855, Samsung Galaxy Note N7000
Edit: Annnnd NINJA'D by FaceDeer! LOL! I'll just leave the slightly simplified working here for anyone who's feeling adventurous.


@BaconButty: I think the problem might've been that your block indentation went pear-shaped: it can happen when typing code in or opening the file in the editor, if you're not careful.

The basic steps you detailed are pretty much correct, though you can do it in fewer.

A gentle reminder to all users: calibre should be closed before mucking in the configuration directory.

Open calibre's configuration directory, select the FFDL ZIP and copy it elsewhere for insurance against mistakes. Next open up the ZIP, go to where the adapter file is located in it, and open it directly from the ZIP archive in a text/code editor.

Tip: It helps if you associate the .py file extension beforehand to the text/code editor you want to use. My weapon of choice is Notepad++; others on various platforms may like Sublime Text, Text Editor, SciTE, Kate, emacs, vi, etc.

Search for the code fragment that's to be replaced. If you want to play it safe, copy the altered code directly as provided in shesgottaread's post, and replace the two lines indicated with the altered version. Otherwise you can strip all the comments (lines starting with #) and just add the one line changing the user agent string, as FaceDeer did above.

Whichever you do, make very sure the code aligns correctly. (This is also why you will want to use something other than Notepad for this.) You may see that the comments (the lines beginning with #) may not quite align. That seems to be fine. In practice what it means is that this line:

Code:
self.opener.addheaders = [('User-agent', 'FFDL/1.6')]
needs to be at the same level of indentation as this line:

Code:
self.story.setMetadata('siteabbrev','ffnet')
This is because of how Python delimits its code blocks (see this for explanations). The three lines of code in shesgottaread's post form a single code block.

Don't forget to change the 'FFDL/1.6' to 'FFDL/1.7.39'. Save your work. WinRAR or 7zip might ask if you want to save the changed file to the archive. Say yes. Open up calibre and see if the FFDL plugin is working. If it's not there, you've stuffed something up-- close calibre and try again. If you've gotten it all right it should be there as usual.

Test if you can download an FFDL story. If it works, congrats, you've successfully modified the plugin.

Last edited by Sefiriot; 09-07-2013 at 12:49 PM. Reason: trimmed post for length
Sefiriot is offline