ytpsort error handling and install script update
This commit is contained in:
parent
26133bf873
commit
ca7369822d
@ -1,3 +1,9 @@
|
|||||||
#/bin/sh
|
#/bin/sh
|
||||||
|
|
||||||
ln -s "$PWD/ytpsort.mjs" ~/.local/bin/ytpsort
|
scripts_dir="$HOME/.local/bin"
|
||||||
|
|
||||||
|
mkdir -p "$scripts_dir"
|
||||||
|
|
||||||
|
ln -s "$PWD/ytpsort.mjs" "$scripts_dir/ytpsort"
|
||||||
|
|
||||||
|
echo "Linked all scripts. Ensure $scripts_dir is in your \$PATH."
|
||||||
|
@ -50,7 +50,13 @@ const body = await fetch("https://www.youtube.com/youtubei/v1/browse?prettyPrint
|
|||||||
})
|
})
|
||||||
}).then(res => res.json())
|
}).then(res => res.json())
|
||||||
|
|
||||||
const rawPlaylistItems = body.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].playlistVideoListRenderer.contents;
|
let rawPlaylistItems = null;
|
||||||
|
try {
|
||||||
|
rawPlaylistItems = body.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].playlistVideoListRenderer.contents;
|
||||||
|
} catch {
|
||||||
|
console.error("Error accessing JSON response fields: YT response possibly changed?");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const viewsRegex = /by .* ((?:\d+,?)+) views .*ago/;
|
const viewsRegex = /by .* ((?:\d+,?)+) views .*ago/;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user