Collect URL, first 'useful' version. Borrowing from GPL v3 code, so not Apache License.

This commit is contained in:
Jim Miller
2011-12-16 11:29:36 -06:00
parent d5c38927fb
commit a9fa06fd4d
4 changed files with 56 additions and 45 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'Apache License'
__license__ = 'GPL v3'
__copyright__ = '2011, Fanficdownloader team'
__docformat__ = 'restructuredtext en'
+1 -1
View File
@@ -3,7 +3,7 @@
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'Apache License'
__license__ = 'GPL v3'
__copyright__ = '2011, Fanficdownloader team'
__docformat__ = 'restructuredtext en'
+53 -42
View File
@@ -3,7 +3,7 @@
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'Apache License'
__license__ = 'GPL v3'
__copyright__ = '2011, Fanficdownloader team'
__docformat__ = 'restructuredtext en'
@@ -15,7 +15,7 @@ if False:
from StringIO import StringIO
from PyQt4.Qt import QDialog, QVBoxLayout, QPushButton, QMessageBox, QLabel
from PyQt4.Qt import (QDialog, QVBoxLayout, QPushButton, QMessageBox, QLabel, QLineEdit)
from calibre.ptempfile import PersistentTemporaryFile
from calibre.ebooks.metadata.epub import get_metadata
@@ -52,18 +52,26 @@ class DemoDialog(QDialog):
self.about_button.clicked.connect(self.about)
self.l.addWidget(self.about_button)
self.marked_button = QPushButton(
'Show books with only one format in the calibre GUI', self)
self.marked_button.clicked.connect(self.marked)
self.l.addWidget(self.marked_button)
# self.marked_button = QPushButton(
# 'Show books with only one format in the calibre GUI', self)
# self.marked_button.clicked.connect(self.marked)
# self.l.addWidget(self.marked_button)
self.view_button = QPushButton(
'View the most recently added book', self)
self.view_button.clicked.connect(self.view)
self.l.addWidget(self.view_button)
# self.view_button = QPushButton(
# 'View the most recently added book', self)
# self.view_button.clicked.connect(self.view)
# self.l.addWidget(self.view_button)
self.label = QLabel('Story URL:')
self.l.addWidget(self.label)
self.msg = QLineEdit(self)
# self.msg.setText(prefs['hello_world_msg'])
self.l.addWidget(self.msg)
self.label.setBuddy(self.msg)
self.ffdl_button = QPushButton(
'Attempt FFDL', self)
'Download Story', self)
self.ffdl_button.clicked.connect(self.ffdl)
self.l.addWidget(self.ffdl_button)
@@ -88,27 +96,29 @@ class DemoDialog(QDialog):
QMessageBox.about(self, 'About the Interface Plugin Demo',
text.decode('utf-8'))
def marked(self):
fmt_idx = self.db.FIELD_MAP['formats']
matched_ids = set()
for record in self.db.data.iterall():
# Iterate over all records
fmts = record[fmt_idx]
# fmts is either None or a comma separated list of formats
if fmts and ',' not in fmts:
matched_ids.add(record[0])
# Mark the records with the matching ids
self.db.set_marked_ids(matched_ids)
# def marked(self):
# fmt_idx = self.db.FIELD_MAP['formats']
# matched_ids = set()
# for record in self.db.data.iterall():
# # Iterate over all records
# fmts = record[fmt_idx]
# # fmts is either None or a comma separated list of formats
# if fmts and ',' not in fmts:
# matched_ids.add(record[0])
# # Mark the records with the matching ids
# self.db.set_marked_ids(matched_ids)
# Tell the GUI to search for all marked records
self.gui.search.setEditText('marked:true')
self.gui.search.do_search()
# # Tell the GUI to search for all marked records
# self.gui.search.setEditText('marked:true')
# self.gui.search.do_search()
def ffdl(self):
config = ConfigParser.SafeConfigParser()
config.readfp(StringIO(get_resources("defaults.ini")))
adapter = adapters.getAdapter(config,"http://test1.com?sid=6646") # http://www.fanfiction.net/s/6439390/1/All_Hallows_Eve") #
print("URL:"+unicode(self.msg.text()))
adapter = adapters.getAdapter(config,unicode(self.msg.text()))
# "http://test1.com?sid=6646") # http://www.fanfiction.net/s/6439390/1/All_Hallows_Eve") #
writer = writers.getWriter("epub",config,adapter)
tmp = PersistentTemporaryFile(".epub")
@@ -116,27 +126,28 @@ class DemoDialog(QDialog):
print("tmp: "+tmp.name)
mi = get_metadata(tmp,extract_cover=False)
self.db.add_books([tmp],["EPUB"],[mi])
self.hide()
QMessageBox.about(self, 'FFDL Metadata',
str(adapter.getStoryMetadataOnly()).decode('utf-8'))
def view(self):
most_recent = most_recent_id = None
timestamp_idx = self.db.FIELD_MAP['timestamp']
# def view(self):
# most_recent = most_recent_id = None
# timestamp_idx = self.db.FIELD_MAP['timestamp']
for record in self.db.data:
# Iterate over all currently showing records
timestamp = record[timestamp_idx]
if most_recent is None or timestamp > most_recent:
most_recent = timestamp
most_recent_id = record[0]
# for record in self.db.data:
# # Iterate over all currently showing records
# timestamp = record[timestamp_idx]
# if most_recent is None or timestamp > most_recent:
# most_recent = timestamp
# most_recent_id = record[0]
if most_recent_id is not None:
# Get the row number of the id as shown in the GUI
row_number = self.db.row(most_recent_id)
# Get a reference to the View plugin
view_plugin = self.gui.iactions['View']
# Ask the view plugin to launch the viewer for row_number
view_plugin._view_books([row_number])
# if most_recent_id is not None:
# # Get the row number of the id as shown in the GUI
# row_number = self.db.row(most_recent_id)
# # Get a reference to the View plugin
# view_plugin = self.gui.iactions['View']
# # Ask the view plugin to launch the viewer for row_number
# view_plugin._view_books([row_number])
def config(self):
self.do_user_config(parent=self)
+1 -1
View File
@@ -3,7 +3,7 @@
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'Apache License'
__license__ = 'GPL v3'
__copyright__ = '2011, Fanficdownloader team'
__docformat__ = 'restructuredtext en'