-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
755 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
open_url_handler () { | ||
urls="$(tr '\n' ' ' < "$1")" | ||
|
||
set -f | ||
IFS=" " | ||
set -- $urls | ||
[ -z "$*" ] && return 0 | ||
unset IFS | ||
|
||
idx="$(jq -r --arg url "$1" '.[]|select(.url==$url).idx' < "$ytfzf_video_json_file")" | ||
referrer="$(jq -r --arg url "$1" '.[]|select(.url==$url).dpage' < "$ytfzf_video_json_file")" | ||
|
||
url_handler_opts="--vid=$idx --referrer=$referrer" | ||
|
||
printf "%s\t" "$ytdl_pref" "$is_audio_only" "$is_detach" "$video_pref" "$audio_pref" | session_temp_dir="${session_temp_dir}" session_cache_dir="${session_cache_dir}" "$url_handler" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
handle_link () { | ||
link=$1 | ||
domain="${link#https://}" | ||
domain="${domain%%/*}" | ||
case "$domain" in | ||
#invidious list found here: https://docs.invidious.io/instances | ||
*youtube*|*invidious*|vid.puffyan.us|yewtu.be|inv.riverside.rocks|yt.artemislena.eu|tube.cthd.icu) | ||
link=$(_get_real_channel_link "$1") | ||
final="https://www.youtube.com/feeds/videos.xml?channel_id=${link##*/}" | ||
;; | ||
*reddit*) final="$link/.rss" ;; | ||
esac | ||
} | ||
|
||
scrape_feed_url () { | ||
IFS=" " | ||
if [ "$1" = ":help" ]; then | ||
printf "%s\n" "Get the rss feed for something | ||
supported searches: | ||
youtube/<channel-name> | ||
<link-to-youtube-channel> | ||
r/subreddit | ||
<link-to-subreddit> | ||
example searches: | ||
youtube/pewdiepie | ||
r/linux" | ||
return 100 | ||
fi | ||
for link in $1; do | ||
case "$link" in | ||
r/*) final="https://www.reddit.com/r/${link#r/}/.rss" ;; | ||
youtube/*) | ||
link="https://www.youtube.com/user/${link#youtube/}" | ||
handle_link "$link" | ||
;; | ||
*) | ||
handle_link "$link" ;; | ||
esac | ||
#i honestly don't even know how it's possible that non-printable characters end up here | ||
final="$(printf "%s" "$final" | sed 's/[^[:print:]]//g')" | ||
printf "%s\n" "$final" | ||
_get_request "$final" -L --head --silent -f > /dev/null|| print_warning "Warning: $final, does not appear to be a real url\n" | ||
done | ||
exit 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
_yt_music_get_playlist_json () { | ||
jq '..|.musicResponsiveListItemRenderer?|select(.!=null)|select(..|.musicResponsiveListItemFlexColumnRenderer?.text.runs|length == 5) | ||
| { | ||
title: .flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text, | ||
duration: .flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[-1].text, | ||
url: "https://music.youtube.com/playlist?list=\(.menu.menuRenderer.items[0].menuNavigationItemRenderer.navigationEndpoint.watchPlaylistEndpoint.playlistId)", | ||
thumbs: .thumbnail.musicThumbnailRenderer.thumbnail.thumbnails[-1].url, | ||
action: "scrape type=yt-music-playlist search=https://music.youtube.com/playlist?list=\(.menu.menuRenderer.items[0].menuNavigationItemRenderer.navigationEndpoint.watchPlaylistEndpoint.playlistId)", | ||
ID: .menu.menuRenderer.items[0].menuNavigationItemRenderer.navigationEndpoint.watchPlaylistEndpoint.playlistId }' | jq '[inputs]' | ||
} | ||
|
||
_yt_music_get_song_json () { | ||
jq '..|.musicResponsiveListItemRenderer?|select(.!=null)|select(..|.musicResponsiveListItemFlexColumnRenderer?.text.runs|length == 7) | ||
| { | ||
title: .flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text, | ||
channel: .flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text, | ||
views: .flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[4].text, | ||
duration: .flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[-1].text, | ||
url: "https://music.youtube.com/watch?v=\(.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId)", | ||
ID: .flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId, | ||
thumbs: .thumbnail.musicThumbnailRenderer.thumbnail.thumbnails[-1].url}' | jq '[inputs]' | ||
} | ||
|
||
scrape_yt_music () { | ||
search="$1" | ||
output_json_file="$2" | ||
_tmp_html="${session_temp_dir}/yt-music.html" | ||
_tmp_json="${session_temp_dir}/yt-music.json" | ||
url="https://music.youtube.com/search" | ||
_get_request "$url" -G --data-urlencode "q=$search" > "$_tmp_html" | ||
|
||
if [ -f $YTFZF_CUSTOM_SCRAPERS_DIR/yt-music-utils/convert-ascii-escape.pl ]; then | ||
utils_path=$YTFZF_CUSTOM_SCRAPERS_DIR/yt-music-utils/convert-ascii-escape.pl | ||
elif [ -f "$YTFZF_SYSTEM_ADDON_DIR"/scrapers/yt-music-utils/convert-ascii-escape.pl ]; then | ||
utils_path="$YTFZF_SYSTEM_ADDON_DIR"/scrapers/yt-music-utils/convert-ascii-escape.pl | ||
else | ||
print_error "The convert-ascii-escape.pl file could not be found\n" | ||
exit 1 | ||
fi | ||
|
||
|
||
sed -n "s/.*data: '\([^']*\)'.*/\1/p" < "$_tmp_html" | "$utils_path" > "$_tmp_json" | ||
{ | ||
_yt_music_get_playlist_json < "$_tmp_json" | ||
_yt_music_get_song_json < "$_tmp_json" | ||
} > "$output_json_file" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
_yt_music_get_playlist_json () { | ||
jq '..|.musicResponsiveListItemRenderer?|select(.!=null)|select(..|.musicResponsiveListItemFlexColumnRenderer?.text.runs|length == 5) | ||
| { | ||
title: .flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text, | ||
duration: .flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[-1].text, | ||
url: "https://music.youtube.com/playlist?list=\(.menu.menuRenderer.items[0].menuNavigationItemRenderer.navigationEndpoint.watchPlaylistEndpoint.playlistId)", | ||
thumbs: .thumbnail.musicThumbnailRenderer.thumbnail.thumbnails[-1].url, | ||
action: "scrape type=yt-music-playlist search=https://music.youtube.com/playlist?list=\(.menu.menuRenderer.items[0].menuNavigationItemRenderer.navigationEndpoint.watchPlaylistEndpoint.playlistId)", | ||
ID: .menu.menuRenderer.items[0].menuNavigationItemRenderer.navigationEndpoint.watchPlaylistEndpoint.playlistId }' | jq '[inputs]' | ||
} | ||
|
||
_yt_music_get_song_json () { | ||
jq '..|.musicResponsiveListItemRenderer?|select(.!=null) | ||
| { | ||
title: .flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text, | ||
channel: .flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[-1].text, | ||
duration: .fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text, | ||
url: "https://music.youtube.com/watch?v=\(.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId)", | ||
ID: .flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId, | ||
thumbs: .thumbnail.musicThumbnailRenderer.thumbnail.thumbnails[-1].url}' | jq '[inputs]' | ||
} | ||
|
||
scrape_yt_music_playlist () { | ||
search="$1" | ||
output_json_file="$2" | ||
_tmp_html="${session_temp_dir}/yt-music-playlist.html" | ||
_tmp_json="${session_temp_dir}/yt-music-playlist.json" | ||
_get_request "$search" > "$_tmp_html" | ||
|
||
if [ -f $YTFZF_CUSTOM_SCRAPERS_DIR/yt-music-utils/convert-ascii-escape.pl ]; then | ||
utils_path=$YTFZF_CUSTOM_SCRAPERS_DIR/yt-music-utils/convert-ascii-escape.pl | ||
elif [ -f "$YTFZF_SYSTEM_ADDON_DIR"/scrapers/yt-music-utils/convert-ascii-escape.pl ]; then | ||
utils_path="$YTFZF_SYSTEM_ADDON_DIR"/scrapers/yt-music-utils/convert-ascii-escape.pl | ||
else | ||
print_error "The convert-ascii-escape.pl file could not be found\n" | ||
exit 1 | ||
fi | ||
|
||
sed -n "s/.*data: '\([^']*\)'.*/\1/p" < "$_tmp_html" | "$utils_path" > "$_tmp_json" | ||
{ | ||
#_yt_music_get_playlist_json < "$_tmp_json" | ||
_yt_music_get_song_json < "$_tmp_json" | ||
} > "$output_json_file" | ||
} |
Oops, something went wrong.