shithub: hell

Download patch

ref: 3107044a2e18be70940e3fe8caac053d9b1a9cd2
parent: f66be6e662ba62d5d21e4e4adb182bb9f398e4fe
author: penny <penny@limitedideas.org>
date: Tue Oct 14 10:10:02 EDT 2025

add /play for media links

--- a/commands.go
+++ b/commands.go
@@ -4,7 +4,7 @@
 	"strings"
 )
 
-var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "view", "bookmarks", "follow", "unfollow", "likes", "help", "reload", "attach", "detach", "pinned", "cat"}
+var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "view", "bookmarks", "follow", "unfollow", "likes", "help", "reload", "attach", "detach", "pinned", "cat", "play"}
 
 func processInput(input string) (command string, arguments string, found bool) {
 
--- a/config.go
+++ b/config.go
@@ -19,7 +19,8 @@
 	ImageViewer   string  `toml:"image_viewer" comment:"System image viewer command."`
 	MediaImport   string  `toml:"media_importer" comment:"Alternative media command used with /import"`
 	FilePicker    string  `toml:"file_picker" comment:"Graphical file picker (or otherwise)"`
-	MediaTag      string   `toml:"media_tag" comment:"text displayed to indicate a media attachment"`
+	MediaTag      string  `toml:"media_tag" comment:"text displayed to indicate a media attachment"`
+	MediaPlayer   string  `toml:"media_player" comment:"Application to pass media URLs to with /play"`
 }
 
 type account_array struct {
@@ -75,6 +76,11 @@
 		prefs.MediaTag = defaultprefs.MediaTag
 		fixed = true
 	}
+	
+	if prefs.MediaPlayer == "" {
+		prefs.MediaPlayer = defaultprefs.MediaPlayer
+		fixed = true
+	}
 	return prefs, fixed
 }
 
@@ -87,6 +93,7 @@
 		MediaImport:   "xdg-open '%s'",
 		FilePicker:    "zenity --file-selection",
 		MediaTag:      "🖼️",
+		MediaPlayer:   "mpv '%s'",
 	}
 	return *prefs
 }
--- a/help.go
+++ b/help.go
@@ -39,7 +39,8 @@
   /resume                      Explicitly unpause the timeline.
   /url <index> [url tag]       Open URL from status content.
                                If no tag is provided, will open the first url.
-                             
+                               
+  /video <index> [url tag]     Like /url but calls configured media player
   /fpost <index>               Add status to account's filters.
   /ufpost <index>              Unfilter status.
   /edit <index> [content]      Set targeted status to [content].
--- a/main.go
+++ b/main.go
@@ -309,6 +309,18 @@
 				}
 				openItemInOS(hc.preferences.Browser, hc.homeref.urlmap[index][urlindex-1])
 				return
+			case "play":
+				_, indexstr, _ := strings.Cut(arguments, " ")
+				urlindex, err := strconv.Atoi(indexstr)
+				if err != nil {
+					urlindex = 1
+				}
+				if urlindex > len(hc.homeref.urlmap[index]) {
+					fmt.Printf("Bad url index\n")
+					return
+				}
+				openItemInOS(hc.preferences.MediaPlayer, hc.homeref.urlmap[index][urlindex-1])
+				return
 			case "view":
 				err := hc.previewPostImages(postItem, hc.preferences.ImageViewer)
 				if err != nil {
--