A Bash/Python script for watching your latest video feeds from your TinyTinyRSS instance using mpv.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
2.1 KiB

import sys
import subprocess
from ttrss.client import TTRClient
client = TTRClient(sys.argv[1], sys.argv[2], sys.argv[3])
client.login()
categ30 = client.get_headlines(feed_id=sys.argv[4], is_cat=True, view_mode="unread", order_by="feed_dates")
# https://git.tt-rss.org/git/tt-rss/wiki/ApiReference#getheadlines
# get_headlines() args:
# + feed_id – Feed id. This is available as the id property of a Feed object. Default is -4 (all feeds).
# + limit – Return no more than this number of headlines. Default is 0 (unlimited, though the server limits to 60).
# + skip – Skip this number of headlines. Useful for pagination. Default is 0.
# + is_cat – The feed_id is a category. Defaults to False.
# + show_excerpt – Include a short excerpt of the article. Defaults to True.
# + show_content – Include full article content. Defaults to False.
# + view_mode – (string = all_articles, unread, adaptive, marked, updated)
# + order_by – The default (None) actually uses "Default" sort. Alternative values are date_reverse (oldest first), and feed_dates (newest first ordered by feed date). This parameter requires ttrss-python > v0.5
# + include_attachments – include article attachments. Defaults to False.
# + since_id – Only include headlines newer than since_id.
# + include_nested – Include articles from child categories. Defaults to True.
for i in categ30:
# print info to terminal output (mpv titlebar does not always show author, i.e., channel name)
print("Now playing:", i.title, "---", i.author)
print("Now playing:", i.link)
# spawn mpv window with video, only return control here when mpv closes
# as a work-around for all the settings resetting for each video, at least lower volume a little
# keep-open=no forces the mpv window to close (and thus return control to this loop)
# x11-name is a unique string which we use in our i3wm config to reset mpv window size and position
subprocess.run(["mpv", i.link, "--volume=50", "--keep-open=no", "--x11-name=ttrss-video-mpv"])
# mark this video as read in your TTRSS feed
client.mark_read(i.id)