2015-09-01 22:08:37 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
2015-08-31 22:45:17 +02:00
|
|
|
|
2019-02-23 06:34:17 +01:00
|
|
|
# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
2015-08-31 22:45:17 +02:00
|
|
|
# Copyright 2015 jnphilipp <me@jnphilipp.org>
|
|
|
|
#
|
|
|
|
# This file is part of qutebrowser.
|
|
|
|
#
|
|
|
|
# qutebrowser is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# qutebrowser is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# Opens all links to feeds defined in the head of a site
|
|
|
|
#
|
2017-07-04 15:43:54 +02:00
|
|
|
# Ideal for use with tabs_are_windows. Set a hotkey to launch this script, then:
|
2015-09-01 22:08:37 +02:00
|
|
|
# :bind gF spawn --userscript openfeeds
|
2015-08-31 22:45:17 +02:00
|
|
|
#
|
|
|
|
# Use the hotkey to open the feeds in new tab/window, press 'gF' to open
|
|
|
|
#
|
|
|
|
|
2015-09-01 22:08:37 +02:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
|
|
|
from bs4 import BeautifulSoup
|
2016-03-24 22:03:29 +01:00
|
|
|
from urllib.parse import urljoin
|
2015-09-01 22:08:37 +02:00
|
|
|
|
2015-09-02 14:02:24 +02:00
|
|
|
with open(os.environ['QUTE_HTML'], 'r') as f:
|
|
|
|
soup = BeautifulSoup(f)
|
|
|
|
with open(os.environ['QUTE_FIFO'], 'w') as f:
|
|
|
|
for link in soup.find_all('link', rel='alternate', type=re.compile(r'application/((rss|rdf|atom)\+)?xml|text/xml')):
|
2016-03-24 22:03:29 +01:00
|
|
|
f.write('open -t %s\n' % urljoin(os.environ['QUTE_URL'], link.get('href')))
|