Rewrote userscript to use BeautifulSoup.
This commit is contained in:
parent
8a1a090dea
commit
1cbc555933
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2015 jnphilipp <me@jnphilipp.org>
|
# Copyright 2015 jnphilipp <me@jnphilipp.org>
|
||||||
#
|
#
|
||||||
@ -20,11 +21,19 @@
|
|||||||
# Opens all links to feeds defined in the head of a site
|
# Opens all links to feeds defined in the head of a site
|
||||||
#
|
#
|
||||||
# Ideal for use with tabs-are-windows. Set a hotkey to launch this script, then:
|
# Ideal for use with tabs-are-windows. Set a hotkey to launch this script, then:
|
||||||
# :bind gF spawn --userscript openfeeds
|
# :bind gF spawn --userscript openfeeds
|
||||||
#
|
#
|
||||||
# Use the hotkey to open the feeds in new tab/window, press 'gF' to open
|
# Use the hotkey to open the feeds in new tab/window, press 'gF' to open
|
||||||
#
|
#
|
||||||
|
|
||||||
grep cat ${QUTE_HTML} | grep "<link[^>]*rel=\"alternate\"[^>]*>" | grep -E "(application/((rss|rdf|atom)\+)?xml|text/xml)" | grep -oE "href=\"([^\"]+)\"" | cut -d\" -f2 | while read -r line ; do
|
import os
|
||||||
echo "open -t ${line}" >> "$QUTE_FIFO"
|
import re
|
||||||
done
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
if os.environ['QUTE_HTML']:
|
||||||
|
soup = BeautifulSoup(open(os.environ['QUTE_HTML'], 'r'))
|
||||||
|
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')):
|
||||||
|
f.write('open -t %s\n' % link.get('href'))
|
||||||
|
f.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user