Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
22d09fb807
@ -121,21 +121,26 @@ rec {
|
|||||||
pattern = "^.*(?P<args>http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+).*$$";
|
pattern = "^.*(?P<args>http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+).*$$";
|
||||||
path = with pkgs; [ curl perl ];
|
path = with pkgs; [ curl perl ];
|
||||||
script = pkgs.writePython3 "url-title" [ "beautifulsoup4" "lxml" ] ''
|
script = pkgs.writePython3 "url-title" [ "beautifulsoup4" "lxml" ] ''
|
||||||
|
import cgi
|
||||||
import sys
|
import sys
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(urllib.request.urlopen(sys.argv[1]), "lxml")
|
req = urllib.request.Request(sys.argv[1])
|
||||||
|
req.add_header('user-agent', 'Reaktor-url-title')
|
||||||
|
resp = urllib.request.urlopen(req)
|
||||||
|
if resp.headers['content-type'].find('text/html') >= 0:
|
||||||
|
soup = BeautifulSoup(resp.read(16000), "lxml")
|
||||||
title = soup.find('title').string
|
title = soup.find('title').string
|
||||||
|
|
||||||
if title:
|
if len(title.split('\n')) > 5:
|
||||||
if len(title) > 512:
|
title = '\n'.join(title.split('\n')[:5])
|
||||||
print('message to long, skipped')
|
|
||||||
elif len(title.split('\n')) > 5:
|
print(title[:450])
|
||||||
print('to many lines, skipped')
|
|
||||||
else:
|
else:
|
||||||
print(title)
|
cd_header = resp.headers['content-disposition']
|
||||||
|
print(cgi.parse_header(cd_header)[1]['filename'])
|
||||||
except: # noqa: E722
|
except: # noqa: E722
|
||||||
pass
|
pass
|
||||||
'';
|
'';
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
krebs-source = {
|
krebs-source = {
|
||||||
nixpkgs.git = {
|
nixpkgs.git = {
|
||||||
ref = "91b286c8935b8c5df4a99302715200d3bd561977";
|
ref = "56fad146a12a6f934d1d5ef875eb729be1b19129";
|
||||||
url = https://github.com/NixOS/nixpkgs;
|
url = https://github.com/NixOS/nixpkgs;
|
||||||
};
|
};
|
||||||
stockholm.file = toString ../.;
|
stockholm.file = toString ../.;
|
||||||
|
@ -71,6 +71,9 @@ with import <stockholm/lib>;
|
|||||||
hashPassword
|
hashPassword
|
||||||
thunderbird
|
thunderbird
|
||||||
dpass
|
dpass
|
||||||
|
|
||||||
|
# we want tensorflow! (with GPU acceleration)
|
||||||
|
python3Packages.tensorflowWithCuda
|
||||||
];
|
];
|
||||||
|
|
||||||
users.users = {
|
users.users = {
|
||||||
|
Loading…
Reference in New Issue
Block a user