… | |
… | |
80 | # MUST be canonical, same as dfe |
80 | # MUST be canonical, same as dfe |
81 | our $STATE_FILE = "/fs/doom/db/doomfrontend.state"; |
81 | our $STATE_FILE = "/fs/doom/db/doomfrontend.state"; |
82 | our $STATE_SHM = "/dev/shm/doomfrontend.state"; |
82 | our $STATE_SHM = "/dev/shm/doomfrontend.state"; |
83 | our @LIRC = ("unix/", "/run/lirc/lircd"); |
83 | our @LIRC = ("unix/", "/run/lirc/lircd"); |
84 | our $CONF_FILE = "/fs/doom/root/dfe.conf"; |
84 | our $CONF_FILE = "/fs/doom/root/dfe.conf"; |
85 | our $VIDEO_DIR = "/fs/doom/var/lib/mythvideo/02_ytd/00_distant_worlds"; |
85 | our $VIDEO_DIR = "/fs/doom/root/00_distant_worlds"; |
86 | our $ARCHIVE_DIR = "/fs/doom/var/lib/mythvideo/02_ytd/00_distant_worlds/00_archive"; |
86 | our $ARCHIVE_DIR = "/fs/doom/root/00_distant_worlds/00_archive"; # was /fs/doom/var/lib/mythvideo/02_ytd/00_distant_worlds/00_archive |
87 | our $MYTHTV_DIR = "/fs/doom/var/lib/mythtv"; |
87 | our $MYTHTV_DIR = "/fs/doom/var/lib/mythtv"; |
88 | our $MEDIAINFO = "/usr/bin/mediainfo"; |
88 | our $MEDIAINFO = "/usr/bin/mediainfo"; |
89 | our $MPV = "mpv"; |
89 | our $MPV = "mpv"; |
90 | our @MPV_ARGS = qw( |
90 | our @MPV_ARGS = qw( |
91 | --audio-client-name=doomfrontend |
91 | --audio-client-name=doomfrontend |
… | |
… | |
883 | } |
883 | } |
884 | } |
884 | } |
885 | |
885 | |
886 | ############################################################################# |
886 | ############################################################################# |
887 | |
887 | |
888 | sub canonpath { |
888 | sub _canonpath { |
889 | my $path = $_[0]; |
889 | my $path = $_[0]; |
|
|
890 | |
|
|
891 | my $file; |
|
|
892 | |
|
|
893 | unless (-d $path) { |
|
|
894 | $path =~ s/((?:^|\/)[^\/]+\z)//; |
|
|
895 | $file = $1; |
|
|
896 | } |
890 | |
897 | |
891 | $path = Cwd::realpath $path; |
898 | $path = Cwd::realpath $path; |
892 | $path = "/fs/$NODENAME$path" unless $path =~ /^\/fs\//; |
899 | $path = "/fs/$NODENAME$path" unless $path =~ /^\/fs\//; |
893 | |
900 | |
|
|
901 | "$path$file" |
|
|
902 | } |
|
|
903 | |
|
|
904 | our $VIDEO_DIR_CANON = _canonpath $VIDEO_DIR; |
|
|
905 | |
|
|
906 | sub canonpath { |
|
|
907 | my $path = _canonpath $_[0]; |
|
|
908 | $path =~ s/^\Q$VIDEO_DIR_CANON\E(\z|\/)/$VIDEO_DIR$1/; |
894 | $path |
909 | $path |
895 | } |
910 | } |
896 | |
911 | |
897 | # check path for mythtv |
912 | # check path for mythtv |
898 | sub is_myth($) { |
913 | sub is_myth($) { |
… | |
… | |
917 | $k = "/$k"; |
932 | $k = "/$k"; |
918 | |
933 | |
919 | push @CONF_PLAYLIST_ORDER, $k |
934 | push @CONF_PLAYLIST_ORDER, $k |
920 | unless $v->{hide}; |
935 | unless $v->{hide}; |
921 | |
936 | |
922 | $v->{cwd} = canonpath $v->{cwd} // $VIDEO_DIR; |
937 | $v->{cwd} = $v->{cwd} ? canonpath $v->{cwd} : $VIDEO_DIR; |
923 | |
938 | |
924 | my $state = $STATE{$k} //= {}; |
939 | my $state = $STATE{$k} //= {}; |
925 | $CONF_PLAYLIST{$k} = $v; |
940 | $CONF_PLAYLIST{$k} = $v; |
926 | $state->{from_conf} = 1; |
941 | $state->{from_conf} = 1; |
927 | } |
942 | } |
… | |
… | |
1055 | sub scan_00_distant_worlds { |
1070 | sub scan_00_distant_worlds { |
1056 | ( |
1071 | ( |
1057 | "", |
1072 | "", |
1058 | [ |
1073 | [ |
1059 | video_sort #d# |
1074 | video_sort #d# |
1060 | @{ scan_video_dir "/fs/doom/root/00_distant_worlds" }, |
1075 | @{ scan_video_dir $VIDEO_DIR }, |
1061 | @{ scan_video_dir "/fs/doom/root/ytnew" }, |
1076 | @{ scan_video_dir "/fs/doom/root/ytnew" }, |
1062 | @{ scan_video_dir "/seagate2tb/sinatar" }, |
1077 | @{ scan_video_dir "/seagate2tb/sinatar" }, |
1063 | ] |
1078 | ] |
1064 | ) |
1079 | ) |
1065 | } |
1080 | } |
… | |
… | |
1094 | my $scan = sub { |
1109 | my $scan = sub { |
1095 | my ($path, $display) = @_; |
1110 | my ($path, $display) = @_; |
1096 | |
1111 | |
1097 | my @dirs; |
1112 | my @dirs; |
1098 | |
1113 | |
|
|
1114 | $path = canonpath $path; |
|
|
1115 | |
1099 | opendir my $fh, $path |
1116 | opendir my $fh, $path |
1100 | or return; |
1117 | or return; |
1101 | for (sort readdir $fh) { |
1118 | for (sort readdir $fh) { |
1102 | next if /^\.\.?$/; |
1119 | next if /^\.\.?$/; |
1103 | stat "$path/$_" or next; |
1120 | stat "$path/$_" or next; |
… | |
… | |
1108 | |
1125 | |
1109 | push @dirs, ["$path/$_", "$display/$dis"]; |
1126 | push @dirs, ["$path/$_", "$display/$dis"]; |
1110 | |
1127 | |
1111 | } elsif (-f _) { |
1128 | } elsif (-f _) { |
1112 | my $dis = dec $_; |
1129 | my $dis = dec $_; |
1113 | push @list, [(substr "$display/$dis", 1), canonpath "$path/$_"]; |
1130 | push @list, [(substr "$display/$dis", 1), "$path/$_"]; |
1114 | } |
1131 | } |
1115 | } |
1132 | } |
1116 | |
1133 | |
1117 | __SUB__->(@$_) |
1134 | __SUB__->(@$_) |
1118 | for @dirs; |
1135 | for @dirs; |
… | |
… | |
1260 | } |
1277 | } |
1261 | |
1278 | |
1262 | sub play_video { |
1279 | sub play_video { |
1263 | ($PLAYING_STATE, $PLAYING_PATH, my $continue) = @_; |
1280 | ($PLAYING_STATE, $PLAYING_PATH, my $continue) = @_; |
1264 | |
1281 | |
1265 | my $playback_start; |
1282 | my $playback_start = 0; |
1266 | |
1283 | |
1267 | if ($continue) { |
1284 | if ($continue) { |
1268 | $playback_start = $PLAYING_STATE->{curpos} // 0; |
1285 | $playback_start = $PLAYING_STATE->{curpos} // 0; |
1269 | } else { |
1286 | } else { |
1270 | my @menu = ([beginning => 0], [cancel => undef]); |
1287 | my @menu = ([beginning => 0], [cancel => undef]); |
… | |
… | |
1314 | |
1331 | |
1315 | $mpv->cmd ("script-message", "osc-visibility", "never", "dummy"); |
1332 | $mpv->cmd ("script-message", "osc-visibility", "never", "dummy"); |
1316 | $mpv->cmd ("set", "vid", "auto"); |
1333 | $mpv->cmd ("set", "vid", "auto"); |
1317 | $mpv->cmd ("set", "aid", "auto"); |
1334 | $mpv->cmd ("set", "aid", "auto"); |
1318 | $mpv->cmd ("set", "sid", "no"); |
1335 | $mpv->cmd ("set", "sid", "no"); |
|
|
1336 | #$mpv->cmd ("set", "sub-delay", "-19.100"); |
|
|
1337 | #$mpv->cmd ("set", "sub-codepage", "UTF-8-BROKEN"); |
1319 | $mpv->cmd ("set", "file-local-options/chapters-file", $mpv->escape_binary ("$mpv_path.chapters")); |
1338 | $mpv->cmd ("set", "file-local-options/chapters-file", $mpv->escape_binary ("$mpv_path.chapters")); |
|
|
1339 | $mpv->cmd ("set", "options/start" => "$playback_start"); # file-local-options, or just start do not work |
1320 | $mpv->cmd ("loadfile", $mpv->escape_binary ($mpv_path)); |
1340 | $mpv->cmd ("loadfile", $mpv->escape_binary ($mpv_path)); |
1321 | $mpv->cmd ("script-message", "osc-visibility", "auto", "dummy"); |
1341 | $mpv->cmd ("script-message", "osc-visibility", "auto", "dummy"); |
1322 | #$mpv->cmd ("playlist-clear"); |
1342 | #$mpv->cmd ("playlist-clear"); |
1323 | |
1343 | |
1324 | my $oid = 100; |
1344 | my $oid = 100; |
… | |
… | |
1361 | } elsif ($INPUT eq "return") { |
1381 | } elsif ($INPUT eq "return") { |
1362 | $status = 1; |
1382 | $status = 1; |
1363 | last; |
1383 | last; |
1364 | |
1384 | |
1365 | } elsif ($INPUT eq "mpv/file-loaded") { # start playing, configure video |
1385 | } elsif ($INPUT eq "mpv/file-loaded") { # start playing, configure video |
1366 | $mpv->cmd ("seek", $playback_start, "absolute+exact") if $playback_start > 0; |
1386 | #$mpv->cmd ("seek", $playback_start, "absolute+exact") if $playback_start > 0; |
1367 | |
1387 | |
1368 | my $target_fps = eval { $mpv->cmd_recv ("get_property", "container-fps") } || 60; |
1388 | my $target_fps = eval { $mpv->cmd_recv ("get_property", "container-fps") } || 60; |
1369 | $target_fps *= play_video_speed_mult; |
1389 | $target_fps *= play_video_speed_mult; |
1370 | set_fps $target_fps; |
1390 | set_fps $target_fps; |
1371 | |
1391 | |
… | |
… | |
1533 | } |
1553 | } |
1534 | |
1554 | |
1535 | $mpv->cmd_recv ("stop"); |
1555 | $mpv->cmd_recv ("stop"); |
1536 | |
1556 | |
1537 | # make sure state is clean, even if its slower |
1557 | # make sure state is clean, even if its slower |
1538 | $mpv->stop; |
1558 | #$mpv->stop; |
1539 | mpv_init; |
1559 | #mpv_init; |
1540 | |
1560 | |
1541 | #if ($DPMS_DISABLE) { |
1561 | #if ($DPMS_DISABLE) { |
1542 | # system "xse", "-dpms"; |
1562 | # system "xse", "-dpms"; |
1543 | #} |
1563 | #} |
1544 | } |
1564 | } |
… | |
… | |
2273 | $pl->{cwd} = canonpath $args->[0]; |
2293 | $pl->{cwd} = canonpath $args->[0]; |
2274 | |
2294 | |
2275 | } else { |
2295 | } else { |
2276 | # playlist, must be all files => create playlist with files |
2296 | # playlist, must be all files => create playlist with files |
2277 | |
2297 | |
2278 | $pl->{full_list} = [map { ref ? $_ : stat_video $_ } @$args]; |
2298 | $pl->{full_list} = [map { ref ? $_ : stat_video canonpath $_ } @$args]; |
2279 | |
2299 | |
2280 | ::input_feed "enter" if @$args == 1; #d# hack: auto-play when single video |
2300 | ::input_feed "enter" if @$args == 1; #d# hack: auto-play when single video |
2281 | } |
2301 | } |
2282 | } |
2302 | } |
2283 | |
2303 | |