mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-12 21:32:58 +01:00
playvid now also deletes live_chat.json
This commit is contained in:
parent
a23f2b95b3
commit
df89a5a7b0
6 changed files with 23 additions and 8 deletions
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722630782,
|
"lastModified": 1723991338,
|
||||||
"narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=",
|
"narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d04953086551086b44b6f3c6b7eeb26294f207da",
|
"rev": "8a3354191c0d7144db9756a74755672387b702ba",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn onEvent(self: *LiveChat, mpv: *c.mpv_handle, ev: *c.mpv_event) !void {
|
||||||
c.MPV_EVENT_PROPERTY_CHANGE => {
|
c.MPV_EVENT_PROPERTY_CHANGE => {
|
||||||
const evprop: *c.mpv_event_property = @ptrCast(@alignCast(ev.data));
|
const evprop: *c.mpv_event_property = @ptrCast(@alignCast(ev.data));
|
||||||
if (std.mem.eql(u8, std.mem.span(evprop.name), "stream-open-filename")) {
|
if (std.mem.eql(u8, std.mem.span(evprop.name), "stream-open-filename")) {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
|
||||||
const str = std.mem.span((@as(?*[*:0]const u8, @ptrCast(@alignCast(evprop.data))) orelse return).*);
|
const str = std.mem.span((@as(?*[*:0]const u8, @ptrCast(@alignCast(evprop.data))) orelse return).*);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ fn tryMain() !void {
|
||||||
|
|
||||||
var srv: ?Server = null;
|
var srv: ?Server = null;
|
||||||
if (env_map.data.get("XDG_RUNTIME_DIR")) |xrd| {
|
if (env_map.data.get("XDG_RUNTIME_DIR")) |xrd| {
|
||||||
var sockaddr_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var sockaddr_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const sockaddr = try std.fmt.bufPrintZ(
|
const sockaddr = try std.fmt.bufPrintZ(
|
||||||
&sockaddr_buf,
|
&sockaddr_buf,
|
||||||
"{s}/mzteinit-{}-{}.sock",
|
"{s}/mzteinit-{}-{}.sock",
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn query(alloc: std.mem.Allocator, queries: []ProcessQuery) !void {
|
||||||
if (!std.ascii.isDigit(c))
|
if (!std.ascii.isDigit(c))
|
||||||
continue :procs;
|
continue :procs;
|
||||||
|
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const cmdline_f = std.fs.openFileAbsolute(
|
const cmdline_f = std.fs.openFileAbsolute(
|
||||||
try std.fmt.bufPrint(&buf, "/proc/{s}/cmdline", .{proc.name}),
|
try std.fmt.bufPrint(&buf, "/proc/{s}/cmdline", .{proc.name}),
|
||||||
.{},
|
.{},
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub fn main() !u8 {
|
||||||
defer _ = gpa.deinit();
|
defer _ = gpa.deinit();
|
||||||
const alloc = gpa.allocator();
|
const alloc = gpa.allocator();
|
||||||
|
|
||||||
var file_buf: [std.posix.PATH_MAX]u8 = undefined;
|
var file_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const file = try findVideoFile(alloc, &file_buf);
|
const file = try findVideoFile(alloc, &file_buf);
|
||||||
|
|
||||||
try std.io.getStdOut().writer().print("playing: `{s}`\n", .{file});
|
try std.io.getStdOut().writer().print("playing: `{s}`\n", .{file});
|
||||||
|
@ -22,6 +22,21 @@ pub fn main() !u8 {
|
||||||
if (try promtForDeletion(file)) {
|
if (try promtForDeletion(file)) {
|
||||||
try std.io.getStdOut().writer().print("deleting: `{s}`\n", .{file});
|
try std.io.getStdOut().writer().print("deleting: `{s}`\n", .{file});
|
||||||
try std.fs.cwd().deleteFile(file);
|
try std.fs.cwd().deleteFile(file);
|
||||||
|
|
||||||
|
// Also delete the live_chat file from yt-dlp if present
|
||||||
|
if (std.mem.lastIndexOfScalar(u8, file, '.')) |dot_idx| {
|
||||||
|
var fname_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
const livechat_fname = try std.fmt.bufPrintZ(
|
||||||
|
&fname_buf,
|
||||||
|
"{s}.live_chat.json",
|
||||||
|
.{file[0..dot_idx]},
|
||||||
|
);
|
||||||
|
|
||||||
|
std.fs.cwd().deleteFile(livechat_fname) catch |e| switch (e) {
|
||||||
|
error.FileNotFound => {},
|
||||||
|
else => return e,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn walk(self: *Self, dir: std.fs.Dir) anyerror!void {
|
||||||
try self.walk(subdir);
|
try self.walk(subdir);
|
||||||
},
|
},
|
||||||
.sym_link => {
|
.sym_link => {
|
||||||
var p_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var p_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const p = try dir.readLink(e.name, &p_buf);
|
const p = try dir.readLink(e.name, &p_buf);
|
||||||
var subdir = dir.openDir(p, .{ .iterate = true }) catch |err| {
|
var subdir = dir.openDir(p, .{ .iterate = true }) catch |err| {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
Loading…
Reference in a new issue