wallabag refresh completed

This commit is contained in:
Anish Lakhwara 2021-12-12 14:39:35 +10:00
commit 81eecc6614
3 changed files with 73 additions and 0 deletions

0
wallabag-refresh/.envrc Normal file
View file

45
wallabag-refresh/main.py Normal file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env python
import json
import requests
from icecream import ic
import time
# settings
my_host = 'http://read.mossnet.lan'
oauth_url = '/oauth/v2/token'
params = {'username': 'anish',
'password': 'wallabag',
'grant_type': 'password',
'client_id': '2_4mo0x9udt4owwwo0kg8g004okgos0ccsgggg8c0o0484kc484s',
'client_secret': '1nv0k19p3mck4sk4kc0wcc8ssc44o80okcggccwk8cckkgww00',
'extension': 'json'}
def main():
# get a new token
header = {}
try:
request = requests.get(my_host+oauth_url, params=params)
content = json.loads(request.content)
access_token = content['access_token']
expires = time.time() + content['expires_in']
header = {'Authorization': "Bearer {0}".format(access_token)}
# dns error
except (requests.exceptions.ConnectionError, requests.exceptions.MissingSchema):
ic("Could not connect")
exit
# get all entries
count = 0
entries = requests.get(my_host+'/api/entries', params=params, headers=header)
entries = json.loads(entries.content)
for entry in entries['_embedded']['items']:
if entry['content'] == 'wallabag can\'t retrieve contents for this article. Please <a href="https://doc.wallabag.org/en/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.\n':
r = requests.patch(my_host+'/api/entries/{0}/reload'.format(entry['id']), params=params, headers=header)
count = count + 1
print("Reloading {0}, title: {1}".format(entry['id'], entry['title']))
print("{} entries reloaded".format(count))
return 0
if __name__ == '__main__':
main()

View file

@ -0,0 +1,28 @@
# shell.nix
{ pkgs ? import <nixpkgs> {} }:
let
wallabagapi = pkgs.python38Packages.buildPythonPackage rec {
pname = "wallabag-client";
version = "1.8.2";
src = pkgs.python38Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-jqd0mehCHX/SVb2YHdDpCwKFrV5FjgLavdaMEo2jmfA=";
};
propagatedBuildInputs = with pkgs.python38Packages; [ httpx setuptools_scm ];
doCheck = false;
};
customPython = pkgs.python38.buildEnv.override {
extraLibs = [ pkgs.python38Packages.requests pkgs.python38Packages.icecream ];
};
in
pkgs.mkShell {
buildInputs = [
customPython
# other dependencies
];
shellHook = ''
# maybe set more env-vars
'';
}