gpodder: synchronize feeds as part of desktop bringup -- not once per launch
This commit is contained in:
@@ -34,6 +34,12 @@ in {
|
|||||||
|
|
||||||
fs.".config/gpodderFeeds.opml".symlink.text = feeds.feedsToOpml wanted-feeds;
|
fs.".config/gpodderFeeds.opml".symlink.text = feeds.feedsToOpml wanted-feeds;
|
||||||
|
|
||||||
|
services.gpodder-ensure-feeds = {
|
||||||
|
description = "synchronize static OPML feeds into gPodder's subscription database";
|
||||||
|
partOf = [ "default" ];
|
||||||
|
startCommand = ''gpodder-ensure-feeds ''${HOME}/.config/gpodderFeeds.opml'';
|
||||||
|
};
|
||||||
|
|
||||||
persist.byStore.plaintext = [
|
persist.byStore.plaintext = [
|
||||||
"Videos/gPodder"
|
"Videos/gPodder"
|
||||||
# if you don't persist its database, you get untracked (and hence non-gc'd) downloads, plus slooow startup.
|
# if you don't persist its database, you get untracked (and hence non-gc'd) downloads, plus slooow startup.
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#!nix-shell -i python3 -p gpodder -p listparser -p python3
|
#!nix-shell -i python3 -p gpodder -p listparser -p python3
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
from typing import Optional
|
||||||
import argparse
|
import argparse
|
||||||
import listparser
|
import listparser
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -10,10 +11,10 @@ import sys
|
|||||||
@dataclass(repr=True)
|
@dataclass(repr=True)
|
||||||
class Feed:
|
class Feed:
|
||||||
url: str
|
url: str
|
||||||
title: str # Optional
|
title: Optional[str]
|
||||||
def __init__(self, url: str, title: str):
|
def __init__(self, url: str, title: Optional[str]):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.title = title if title else None
|
self.title = title if title else None # coerce title="" -> None
|
||||||
|
|
||||||
def __eq__(self, other: "Feed") -> bool:
|
def __eq__(self, other: "Feed") -> bool:
|
||||||
return self.url == other.url and \
|
return self.url == other.url and \
|
||||||
@@ -61,7 +62,7 @@ def partition_feeds(wanted: list[Feed], has: list[Feed]) -> Partitioned:
|
|||||||
def remove_feed(feed: Feed):
|
def remove_feed(feed: Feed):
|
||||||
subprocess.check_output(["gpo", "unsubscribe", feed.url])
|
subprocess.check_output(["gpo", "unsubscribe", feed.url])
|
||||||
|
|
||||||
def remove_feeds(feeds: list[str]):
|
def remove_feeds(feeds: list[Feed]):
|
||||||
if not feeds:
|
if not feeds:
|
||||||
print("removing extra feeds: (none)")
|
print("removing extra feeds: (none)")
|
||||||
return
|
return
|
||||||
@@ -71,7 +72,7 @@ def remove_feeds(feeds: list[str]):
|
|||||||
for f in feeds:
|
for f in feeds:
|
||||||
remove_feed(f)
|
remove_feed(f)
|
||||||
|
|
||||||
def add_feeds(opml_path: str, feeds: list[str]):
|
def add_feeds(opml_path: str, feeds: list[Feed]):
|
||||||
if not feeds:
|
if not feeds:
|
||||||
print("adding missing feeds: (none)")
|
print("adding missing feeds: (none)")
|
||||||
return
|
return
|
||||||
|
@@ -1,7 +1,12 @@
|
|||||||
|
# gpodder keeps all its feeds in a sqlite3 database.
|
||||||
|
# the binary provided here, `gpodder-ensure-feeds`, may be run to import
|
||||||
|
# my nix-synchronized feeds into gpodder, and remove any extras i've since deleted.
|
||||||
|
# repeat imports are deduplicated by url, even when offline.
|
||||||
|
# suggested usage: `gpodder-ensure-feeds ~/.config/gpodderFeeds.opml` as part of activation or some default .service
|
||||||
|
|
||||||
{
|
{
|
||||||
gpodder,
|
gpodder,
|
||||||
listparser,
|
listparser,
|
||||||
makeWrapper,
|
|
||||||
static-nix-shell,
|
static-nix-shell,
|
||||||
symlinkJoin,
|
symlinkJoin,
|
||||||
}:
|
}:
|
||||||
@@ -20,26 +25,6 @@ in
|
|||||||
(symlinkJoin {
|
(symlinkJoin {
|
||||||
name = "${gpodder.pname}-configured";
|
name = "${gpodder.pname}-configured";
|
||||||
paths = [ gpodder remove-extra ];
|
paths = [ gpodder remove-extra ];
|
||||||
nativeBuildInputs = [
|
|
||||||
makeWrapper
|
|
||||||
];
|
|
||||||
|
|
||||||
# gpodder keeps all its feeds in a sqlite3 database.
|
|
||||||
# we can configure the feeds externally by wrapping gpodder and just instructing it to import
|
|
||||||
# a feedlist every time we run it.
|
|
||||||
# repeat imports are deduplicated by url, even when offline.
|
|
||||||
postBuild = ''
|
|
||||||
wrapProgram $out/bin/gpodder \
|
|
||||||
$extraMakeWrapperArgs \
|
|
||||||
--run "$out/bin/gpodder-ensure-feeds"' ~/.config/gpodderFeeds.opml "$@" || true' \
|
|
||||||
--run 'while [[ -n "$1" && "$1" != -- && "$1" != --help ]]; do shift; done ; if [[ "$1" == --help ]]; then exit; elif [[ "$1" == -- ]]; then shift; fi'
|
|
||||||
|
|
||||||
# fix up the .desktop file to invoke our wrapped application
|
|
||||||
# (rather, invoke `gpodder` by PATH, which could be this, or an outer layer of wrapping)
|
|
||||||
orig_desktop=$(readlink $out/share/applications/gpodder.desktop)
|
|
||||||
unlink $out/share/applications/gpodder.desktop
|
|
||||||
sed "s:Exec=.*/gpodder:Exec=gpodder:" $orig_desktop > $out/share/applications/gpodder.desktop
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit gpodder remove-extra;
|
inherit gpodder remove-extra;
|
||||||
|
Reference in New Issue
Block a user