Skip to content

Commit

Permalink
shareUrl() bug fix; added getting-starting and known-issues to home page
Browse files Browse the repository at this point in the history
  • Loading branch information
Monty Hindman committed Feb 5, 2025
1 parent 817795a commit 74961dc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
48 changes: 48 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,54 @@

</div>

<div style="font-size:22px;">

To get started:

<ul>
<li>Copy a YouTube URL.</li>
<li>Press 'u' and paste the URL and enter when prompted.</li>
<li>Press 'h' for help.</li>
<li>Experiment with the other commands.</li>
</ul>

</div>
<div style="font-size:22px;">

Some known issues:

<ul>
<li>
If you try to load the page for the first time in
a browser tab and nothing appears, just reload.
</li>
<li>
If LoopLlama commands do nothing or do unexpected things
you might have clicked the video frame, giving it
focus for your keyboard actions. Just click somewhere
outside the video frame to give the focus back to LoopLlama.
</li>
<li>
The first time you pause a video, YouTube will display
suggested videos that will interfere with your view
of the screen. Click the X to dismiss the suggestions,
then click outside the video frame. Future pauses will
not block your view.
</li>
<li>
LoopLlama does not support the less common YouTube URL formats.
</li>
<li>
YouTube disallows some videos. They will communicate that
explicitly.
</li>
<li>
I know Python. Javascript, not so much.
</li>
</ul>

</div>

</body>

</html>
Expand Down
14 changes: 9 additions & 5 deletions loopllama/loopllama.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Reference:
- Some videos to use when working on the code.
Catfish: https://www.youtube.com/watch?v=zP4lYpsfL8c
Catfish: https://www.youtube.com/watch?v=zP4lYpsfL8c [blocked; see below]
Muddy: https://www.youtube.com/watch?v=bnsw4sySaxw
Hudson: https://www.youtube.com/watch?v=HxTU8xylgMw
Jack Ruch: https://www.youtube.com/watch?v=WUm3X_BBQw0
Expand Down Expand Up @@ -698,13 +698,13 @@ function shareUrl() {
curr = new URL(window.location.href);
u = new URL(curr.origin + curr.pathname)

// Copy non-null vi info into the URL's search params.
// Copy non-null/non-undefined vi info into the URL's search params.
p = u.searchParams;
for ([k, v] of Object.entries(vi)) {
if (LOOP_KEYS.includes(k) && loopIsDefined(v)) {
v = v.start.toFixed(2) + '-' + v.end.toFixed(2);
p.set(k, v);
} else if (v !== null) {
} else if (v != null) {
v = typeof v == 'number' ? v.toFixed(2) : v.toString();
p.set(k, v);
}
Expand Down Expand Up @@ -953,12 +953,16 @@ function getReplySetNudge(msg, defReply) {
}

function urlToVideoId(txt) {
// Takes a URL string. Returns the 'v' or 'vid' query parameter or null.
// Takes a URL string and tries to get video ID via:
// 'v' query parameter; # https://www.youtube.com/watch?v=F6va6tg62qg
// 'vid' query parameter;
// URL path. # https://youtu.be/F6va6tg62qg
// Returns video ID or null.
var url, p;
try {
url = new URL(txt);
p = url.searchParams;
return p.get('v') || p.get('vid');
return p.get('v') || p.get('vid') || url.pathname.substring(1) || null
}
catch (err) {
return null;
Expand Down

0 comments on commit 74961dc

Please sign in to comment.