Tired computer science student. More to this profile coming soon.
tsukki9696 / magatama Goto Github PK
View Code? Open in Web Editor NEWPython script that fetches random anime and manga based on genre using the Jikan API.
Python script that fetches random anime and manga based on genre using the Jikan API.
i rewrote a more minimalistic version of this program in shell, for fun, thought i'd share it here:
the only dependencies are fzf
and mpv
(and a posix shell to run the script duh
#!/bin/sh
genre_id=$(curl -s "https://api.jikan.moe/v4/genres/anime" | tr '{' '\n' |
sed -nE "s@.*\"mal_id\":([0-9]*).*\"name\":\"([^\"]*)\".*@\1\t\2@p" | fzf --with-nth 2.. | cut -f1)
page_number=$(shuf -i 1-9 -n1)
anime_name=$(curl -s "https://api.jikan.moe/v4/anime?page=${page_number}&genres=${genre_id}" | tr '{' '\n' |
sed -nE "s@.*\"title\":\"([a-zA-Z0-9 ^\"]*)\".*@\1@p" | sort -u | shuf | head -1)
printf "\033[0;35m%s\033[0m\n" "Searching for $anime_name..."
query=$(printf "%s" "$anime_name" | tr ' ' '+')
choice=$(curl -s "https://yugenanime.tv/discover/?q=${query}" | sed -nE "s@.*href=\"([^\"]*)\" title=\"([^\"]*)\".*@\1\t\2@p" | head -1)
[ -z "$choice" ] && exit 1
anime_id=$(printf "%s" "$choice" | cut -f1)
anime_title=$(printf "%s" "$choice" | cut -f2)
tmp_episode_info=$(curl -s "https://yugenanime.tv${anime_id}watch/" | sed -nE "s@.*href=\"/([^\"]*)\" title=\"([^\"]*)\".*@\1\t\2@p" | head -1)
tmp_href=$(printf "%s" "$tmp_episode_info" | cut -f1)
ep_title=$(printf "%s" "$tmp_episode_info" | cut -f2)
yugen_id=$(curl -s "https://yugenanime.tv/$tmp_href" | sed -nE "s@.*id=\"main-embed\" src=\".*/e/([^/]*)/\".*@\1@p")
episode_info=$(printf "%s\t%s" "$yugen_id" "$ep_title")
[ -z "$episode_info" ] && exit 1
episode_id=$(printf "%s" "$episode_info" | cut -f1)
episode_title=$(printf "%s" "$episode_info" | cut -f2)
[ "$episode_id" = "$episode_title" ] && episode_title=""
"\033[0;35m%s\033[0m\n" "Playing $anime_title - Ep $episode_title"
json_data=$(curl -s 'https://yugenanime.tv/api/embed/' -X POST -H 'X-Requested-With: XMLHttpRequest' --data-raw "id=$episode_id&ac=0")
[ -z "$json_data" ] && exit 1
video_link=$(printf "%s" "$json_data" | tr '{}' '\n' | sed -nE "s@.*\"hls\": \[\"([^\"]*)\".*@\1@p")
# hls_link_2=$(printf "%s" "$json_data" | tr '{}' '\n' | sed -nE "s@.*hls.*, \"([^\"]*)\".\]*@\1@p")
# gogo_link=$(printf "%s" "$json_data" | tr '{}' '\n' | sed -nE "s@.*\"src\": \"([^\"]*)\", \"type\": \"embed.*@\1@p")
[ -z "$video_link" ] && exit 1
# printf "Playing %s - Ep %s\n" "$anime_title" "$episode_title"
# print the above in blue
printf "\033[0;34m%s\033[0m\n" "Playing $anime_title - Ep $episode_title"
mpv --force-media-title="$anime_title - Ep $episode_title" "$video_link"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.