Skip to content

Commit e3e7c79

Browse files
committed
feat: Add media acquisition tools (yt-dlp, mov-cli, transmission, media-manager)
1 parent 7b50bb3 commit e3e7c79

8 files changed

Lines changed: 107 additions & 0 deletions

File tree

programs/media-manager.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{ pkgs, ... }:
2+
3+
let
4+
# List of trusted media sources (add new sites here!)
5+
mediaSources = {
6+
archive = "https://archive.org/details/";
7+
youtube = "https://www.youtube.com/results?search_query=";
8+
topflix = "https://topflix.fm/search/";
9+
documentary = "https://documentaryheaven.com/?s=";
10+
vidsrc = "https://vidsrc.me/embed/";
11+
assistir = "https://assistir.biz/?s=";
12+
upnovelas = "https://upnovelas.com/?s=";
13+
pobleflix = "https://pobleflix.fast/";
14+
vizer = "https://vizer.lol/pesquisar/";
15+
plutotv = "https://pluto.tv/on-demand/";
16+
};
17+
18+
# Generate formatted string for the shell helper
19+
sourceList = builtins.concatStringsSep "\n" (
20+
map (name: "${name} - ${builtins.getAttr name mediaSources}") (builtins.attrNames mediaSources)
21+
);
22+
in
23+
{
24+
programs.bash.initExtra = ''
25+
# Media Source Manager Helper
26+
# Usage:
27+
# mm list - List saved sources
28+
# mm go - Interactive search using fzf to pick a source
29+
mm() {
30+
case "$1" in
31+
"list")
32+
echo -e "\033[1;34m--- Saved Media Sources ---\033[0m"
33+
echo "${sourceList}" | column -t -s "-"
34+
;;
35+
"go")
36+
local source=$(echo "${sourceList}" | fzf --prompt="Select Source: " | awk '{print $NF}')
37+
if [ -n "$source" ]; then
38+
echo -e "\033[1;32mURL available:\033[0m $source"
39+
# Copying to clipboard if needed (platform dependent)
40+
# echo -n "$source" | xclip -selection clipboard 2>/dev/null
41+
fi
42+
;;
43+
*)
44+
echo "Usage: mm [list|go]"
45+
echo "To download found media: b [URL]"
46+
;;
47+
esac
48+
}
49+
'';
50+
}

programs/mov-cli.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{ pkgs, ... }:
2+
{
3+
home.packages = with pkgs; [
4+
mov-cli
5+
mpv
6+
];
7+
}

programs/transmission.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{ pkgs, ... }:
2+
{
3+
home.packages = with pkgs; [
4+
transmission_4
5+
tremc
6+
];
7+
}

programs/yt-dlp.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ pkgs, ... }:
2+
{
3+
home.packages = [ pkgs.yt-dlp ];
4+
programs.bash.shellAliases = {
5+
b = "yt-dlp --downloader aria2c --downloader-args 'aria2c:-x 16 -s 16 -k 1M' --embed-metadata -f 'bestvideo+bestaudio/best' --merge-output-format mp4";
6+
bmusic = "yt-dlp -x --audio-format mp3 --downloader aria2c --downloader-args 'aria2c:-x 16 -s 16 -k 1M'";
7+
};
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def test_media_manager_installed(home_manager_build):
2+
"""Verifies that the Media Manager function is in the bashrc."""
3+
bashrc = home_manager_build / "home-files/.bashrc"
4+
assert bashrc.exists()
5+
6+
content = bashrc.read_text()
7+
assert "mm()" in content
8+
assert "archive.org" in content
9+
assert "--- Saved Media Sources ---" in content

tests/programs/test_mov-cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def test_mov_cli_installed(home_manager_build):
2+
"""Verifies mov-cli and mpv installation."""
3+
mov_bin = home_manager_build / "home-path/bin/mov-cli"
4+
mpv_bin = home_manager_build / "home-path/bin/mpv"
5+
6+
assert mov_bin.exists()
7+
assert mpv_bin.exists()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def test_transmission_installed(home_manager_build):
2+
"""Verifies transmission and tremc installation."""
3+
# Transmission package usually provides transmission-daemon, transmission-cli, etc.
4+
# We check for the daemon or cli.
5+
trans_bin = home_manager_build / "home-path/bin/transmission-daemon"
6+
tremc_bin = home_manager_build / "home-path/bin/tremc"
7+
8+
assert trans_bin.exists()
9+
assert tremc_bin.exists()

tests/programs/test_yt-dlp.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def test_yt_dlp_installed(home_manager_build):
2+
"""Verifies yt-dlp installation and aliases."""
3+
bin_path = home_manager_build / "home-path/bin/yt-dlp"
4+
assert bin_path.exists()
5+
6+
def test_yt_dlp_aliases(home_manager_build):
7+
bashrc = home_manager_build / "home-files/.bashrc"
8+
content = bashrc.read_text()
9+
assert "alias b=" in content
10+
assert "alias bmusic=" in content

0 commit comments

Comments
 (0)