Tech: neet

So this is probably the favorite script I wrote, and maybe this one actually saved me time, probably not though.

neet is "a script to easily play and manage your anime/drama/series":

I was tired of manually cding to an animu or series directory, trying to remember the last episode I watched, finding the file for that episode (by hitting tab a few times), opening the file with mpv, et cetera. So I tried to write a script that does this automatically, the only thing you need to provide neet with is a config file where the media name is specified, the current watching episode number, and the total number of episodes. This is my current config:

#!/bin/fish

set name 'Monster'
set current 18
set total 50

# set name 'Mare'
# set current 3
# set total 156
# set userpath 'Mare/Week 01~The Witch-Princess Birthday Cake'
# set userregex '.*#[0 ]*'$current'[^0-9].*$'

...

Like you can see I'm currently watching episode 18 of a series called "Monster". I'm also watching a series called Mare, but I'm not actively watching it, so it's commented out. You might notices that Mare has two more specified variables, I'll explain these later.

neet also has an actual config file where you set your media directory, player command, and more. This file should be fairly self explanatory:

#!/bin/fish

# Set media dir location
set mediadir $HOME/media/videos

# Set video player command
set playercommand mpv --fullscreen --no-pause

# Set colors
set foreground normal
set bright yellow --bold
set dark black --bold

# Run the following commands before starting mpv
# (to pause mpd for example)
function userfunction
	# Pause mpc
	mpc -q pause

	# Close clock popup
	if test (pgrep -f 'n30f -d -x 871')
		pkill -n -f 'n30f -x 871'
		pkill -f 'n30f -x 857'
		pkill -f 'lemonbar -g 168x20'
	end

	# Close music popup
	if test (pgrep -f 'n30f -x 1587')
		pkill -f 'n30f -x 1753'
		pkill -f 'lemonbar -g 140x20'
		pkill -f 'n30f -x 1587'
		pkill -f -n 'mpc idleloop player'
	end

	# Close todo popup
	pkill -f "micro $HOME/.todo"
end

Anyways, when you execute neet it will search $mediadir ($HOME/media/videos for me) for a directory that's closest to the media name, in my case that's currently Monster. It does this using a very complicated fuzzy search algorithm I wrote (ok, it's actually a glorified set of for loops and if statements.).

Next neet will look for the episode 18 file, it does this using a few regexs, not fail proof, but it work 95% of the time. In case the previous fuzzy directory search or the file match regex fails, you can specify your own directory and regex, with the variables userpath and userregex. You can see me using these for "Mare".

Once the directory and file have been found it will execute $playercommand $mediadir/$path/$file. Of course neet has some more cool options besides simply searching for the right episode and launching it. For example:

Et cetera, you get the idea.

Screenshots

Finally, here are some screenshots of the various aspects of neet in action, hopefully it will clear things up a bit:

Notes

I plan on rewriting neet in Go someday. I already started porting it during boring college hours, and I promise you, I'll finish it soon™.