Ejemplo n.º 1
0
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, "Rss Downloader Options", size=(700, 700))

        notebook = wx.Notebook(self, -1)

        self.integration_panel = DownloadOptionsPanel(notebook)
        notebook.AddPage(self.integration_panel, "Integration Method")

        self.rss_feed_list_editor = ListEditorCtrl(notebook, "Feed URLs", config().get_key("FEED_URLS"), size=(500, 200))
        notebook.AddPage(self.rss_feed_list_editor, "Feed URLs")

        self.match_regexp_list_editor = ListEditorCtrl(notebook, "Match Regexps", config().get_key("MATCH_TORRENTS"))
        notebook.AddPage(self.match_regexp_list_editor, "Match Regexps")

        self.growl_panel = GrowlOptionsPanel(notebook)
        notebook.AddPage(self.growl_panel, "Growl")

        okbutton = wx.Button(self, wx.ID_OK)
        okbutton.SetDefault()

        cancelbutton = wx.Button(self, wx.ID_CANCEL)

        dlgsizer = wx.StdDialogButtonSizer()
        dlgsizer.AddButton(okbutton)
        dlgsizer.AddButton(cancelbutton)
        dlgsizer.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(dlgsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
Ejemplo n.º 2
0
def _add_search_to_history(history_item):
    history = _get_search_history()

    if history_item in history:
        # already in history.  just move it to the top
        history.remove(history_item)
    elif len(history) >= SEARCH_HISTORY_MAX_LEN:
        # truncate history
        history.pop(0)

    history.append(history_item)

    config().set_key('SEARCH_HISTORY', history)
Ejemplo n.º 3
0
    def OnNewTorrentSeen(self, evt):
        evt.Skip()

        # send the growl notification if enabled
        if config().get_key('ENABLE_GROWL') and config().get_key('ENABLE_GROWL_NEW_TORRENT_NOTIFICATION'):
            self.growler.send_new_torrent_notification(evt.torrent)

        #self.mainwindow.tbicon.ShowBalloon(
        #        "New torrent",
        #        "%s seen" % evt.torrent.name,
        #        1 * 1000,
        #        wx.ICON_INFORMATION)

        log.info('NEW: %s', evt.torrent.name)
Ejemplo n.º 4
0
    def OnTorrentDownloaded(self, evt):
        evt.Skip()

        # send the growl notification if enabled
        if config().get_key('ENABLE_GROWL') and config().get_key('ENABLE_GROWL_DOWNLOAD_NOTIFICATION'):
            self.growler.send_download_notification(evt.torrent)

        self.mainwindow.tbicon.ShowBalloon(
                "New torrent downloaded",
                "%s was downloaded" % evt.torrent.name,
                1 * 1000,
                wx.ICON_INFORMATION)

        log.info('Downloaded "%s"', evt.torrent.name)
Ejemplo n.º 5
0
    def find_new_entries(self):
        """Find all new entries in all feeds
        """
        new_entries = []

        for rss_feed_url in config().get_key('FEED_URLS'):
            for entry in feed.get_rss_feed_entries(rss_feed_url):
                try:
                    # find out if it's new
                    self.db.query_torrents().filter_by(name=entry['title']).one()
                except NoResultFound:
                    # it's new
                    db_entry = db.Torrent(entry['title'], entry['link'])

                    # save it to the database
                    if not self.db.save_torrent(db_entry):
                        log.warning("Unable to commit torrent to database: %s", db_entry.name)
                        raise Exception("Unable to commit torrent to database: %s" % db_entry.name)

                    new_entries.append(db_entry)

                    # notify the app that a new torrent was seen
                    evt = NewTorrentSeenEvent()
                    evt.torrent = db_entry
                    wx.PostEvent(wx.GetApp(), evt)
                else:
                    # not new. ignore
                    continue

        return new_entries
Ejemplo n.º 6
0
def add_torrent_to_client(name, url):
    integration_method = config().get_key('TORRENT_INTEGRATION_METHOD')
    log.debug('Torrent integration method: %s', integration_method)

    downloader = TORRENT_INTEGRATION_TRANSLATION[integration_method]

    log.debug('Downloading %s', url)
    return downloader(name + '.torrent', url)
Ejemplo n.º 7
0
    def load_app_image(self, filename):
        log.debug('loading app image: %s', filename)

        path = os.path.join(config().get_app_path(), 'res', filename)

        if not os.path.exists(path):
            log.error('load_app_image: %s does not exist', filename)

        assert os.path.exists(path)

        return wx.Image(path, wx.BITMAP_TYPE_PNG)
Ejemplo n.º 8
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        self.enable_growl = wx.CheckBox(self, -1, "Enable Growl Support")
        self.enable_growl.SetValue(config().get_key('ENABLE_GROWL'))

        self.enable_download_notifications = wx.CheckBox(self, -1, "Enable Download Notifications")
        self.enable_download_notifications.SetValue(config().get_key('ENABLE_GROWL_DOWNLOAD_NOTIFICATION'))

        self.enable_new_torrent_notifications = wx.CheckBox(self, -1, "Enable New Torrent Notifications")
        self.enable_new_torrent_notifications.SetValue(config().get_key('ENABLE_GROWL_NEW_TORRENT_NOTIFICATION'))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.enable_growl, 0, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.enable_download_notifications, 0, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.enable_new_torrent_notifications, 0, wx.EXPAND | wx.ALL, 5)

        self.OnEnableGrowlChanged(None)

        self.Bind(wx.EVT_CHECKBOX, self.OnEnableGrowlChanged, self.enable_growl)
        self.SetSizer(sizer)
Ejemplo n.º 9
0
    def __init__(self):
        self.engine = None

        filename = 'rss_downloader.db'

        self.db_file_path = os.path.join(
                config().get_config_path(), filename)
        self.db_file_path.replace('\\', '/')

        # backwards compatibility with old broken location
        if not os.path.exists(self.db_file_path):
            if os.path.exists(filename):
                os.rename(fielname, self.db_file_path)
Ejemplo n.º 10
0
def deluge_web_ui_downloader(filename, url):
    log.info('Adding %s to client through deluge WebUI', filename)
    try:
        client = DelugeWebUIClient(config().get_key('DELUGE_WEB_UI_URL'))

        log.debug('Logging in')
        response = client.login(config().get_key('DELUGE_WEB_UI_PASSWORD'))
        if not response:
            return False

        log.debug('Checking session')
        response = client.check_session()
        if not response:
            return False

        log.debug('Downloading torrent locally')
        file_path = client.download_torrent_from_url(url)
        if not response:
            return False

        log.debug('Getting config values')
        options = client.get_config_values(*DELUGE_CONFIG_KEYS)

        #TODO: Just for debugging
        options['add_paused'] = True

        torrent = {
            'path': file_path,
            'options': options,
        }

        log.info('Finally, adding torrent')
        result = client.add_torrents(torrent)

        if not result:
            return False
    except Exception, e:
        log.exception('Error while adding torrent to client')
        return False
Ejemplo n.º 11
0
def watch_folder_downloader(filename, url):
    log.info('Adding %s to client through watch folder', filename)
    try:
        response = urllib2.urlopen(url)
        content = response.read()

        log.debug('Downloaded %d byte torrent file', len(content))

        watch_folder = config().get_key('DOWNLOAD_DIRECTORY')

        log.debug('Watch folder set to "%s"', watch_folder)

        filename = os.path.join(watch_folder, filename)

        with open(filename, 'wb') as fd:
            fd.write(content)

    except Exception, e:
        log.exception('Error while downloading torrent to watch folder')
        return False
Ejemplo n.º 12
0
    def check_new_entries(self, new_entries):
        """Check all new entries to see if they match any of the regular expressions
        """
        matched_entries = []

        # check all new entries
        for entry in new_entries:

            # check all regular expressions against the entry
            for match_regexp in config().get_key('MATCH_TORRENTS'):

                # If it matches a regular expression,
                if re.match(match_regexp, entry.name, re.IGNORECASE):

                    # add it to the match list
                    matched_entries.append(entry)

                    # and stop checking it
                    continue

        return matched_entries
Ejemplo n.º 13
0
        # send the growl notification if enabled
        if config().get_key('ENABLE_GROWL') and config().get_key('ENABLE_GROWL_DOWNLOAD_NOTIFICATION'):
            self.growler.send_download_notification(evt.torrent)

        self.mainwindow.tbicon.ShowBalloon(
                "New torrent downloaded",
                "%s was downloaded" % evt.torrent.name,
                1 * 1000,
                wx.ICON_INFORMATION)

        log.info('Downloaded "%s"', evt.torrent.name)

    def load_app_image(self, filename):
        log.debug('loading app image: %s', filename)

        path = os.path.join(config().get_app_path(), 'res', filename)

        if not os.path.exists(path):
            log.error('load_app_image: %s does not exist', filename)

        assert os.path.exists(path)

        return wx.Image(path, wx.BITMAP_TYPE_PNG)


if __name__ == '__main__':
    app = RssDownloaderApp(False)
    reactor.run()
    config().save()
    log.debug('Exiting')
Ejemplo n.º 14
0
def _get_search_history():
    return config().get_key('SEARCH_HISTORY')
Ejemplo n.º 15
0
 def CommitChanges(self):
     self.integration_panel.CommitChanges()
     self.growl_panel.CommitChanges()
     config().set_key("FEED_URLS", self.rss_feed_list_editor.GetListItems())
     config().set_key("MATCH_TORRENTS", self.match_regexp_list_editor.GetListItems())
Ejemplo n.º 16
0
 def CommitChanges(self):
     config().set_key('ENABLE_GROWL', self.enable_growl.GetValue())
     config().set_key('ENABLE_GROWL_DOWNLOAD_NOTIFICATION', self.enable_download_notifications.GetValue())
     config().set_key('ENABLE_GROWL_NEW_TORRENT_NOTIFICATION', self.enable_new_torrent_notifications.GetValue())