feeds: port the update.sh script to use our own feedsearch package instead of the deployed version
This commit is contained in:
parent
b6d94c2e08
commit
942c581107
|
@ -1,10 +1,24 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p curl jq
|
#!nix-shell -i python3 -p "python3.withPackages (ps: [ ps.feedsearch-crawler ])"
|
||||||
|
|
||||||
set -xeu -o pipefail
|
from feedsearch_crawler import search, sort_urls
|
||||||
|
from feedsearch_crawler.crawler import coerce_url
|
||||||
|
|
||||||
url="$1"
|
import json
|
||||||
jsonPath="$2"
|
import sys
|
||||||
|
url, jsonPath = sys.argv[1:]
|
||||||
|
|
||||||
apiQuery="https://feedsearch.dev/api/v1/search?url=$url"
|
url = coerce_url(url, default_scheme="https")
|
||||||
curl -X GET "$apiQuery" | jq '.[0]' > "$jsonPath"
|
items = search(url)
|
||||||
|
items = sort_urls(items)
|
||||||
|
|
||||||
|
# print all results
|
||||||
|
serialized = [item.serialize() for item in items]
|
||||||
|
for item in serialized:
|
||||||
|
print(json.dumps(item, sort_keys=True, indent=2))
|
||||||
|
|
||||||
|
# save the first result to disk
|
||||||
|
keep = serialized[0] if serialized else {}
|
||||||
|
results = json.dumps(keep, sort_keys=True, indent=2)
|
||||||
|
with open(jsonPath, "w") as out:
|
||||||
|
out.write(results)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user