dvargas92495 / SmartBlocks

Useful examples from developer community for Roam42 SmartBlocks
146 stars 6 forks source link

YouTube Timestamps #2

Open GitMurf opened 4 years ago

GitMurf commented 4 years ago

✂️ Copy of your #42SmartBlock from Roam

HERE IS A DEMO (click the GIF to start it over)

youtube timestamp button2



BONUS: Embed a youtube link in proper Roam format & add timestamp button underneath it


HERE IS A DEMO

youtube timestamp embed



THIS IS THE OLD VERSION WITHOUT THE BUTTON



📋 Describe the SmartBlock

I created a SmartBlock to access the current timestamp while watching a YouTube video so that you can quickly add notes by doing ;;YouTube which inserts the timestamp automatically and then you can write some notes about it. Make sure to install CCC's YouTube Player script first (see Prerequisites below).

✅ Describe any prerequisites or dependencies that are required for this SmartBlock

You need to first install CCC's awesome YouTube player script. See links to Tweet and Gist below.

📷 Screenshot of your #42SmartBlock workflow/template from Roam

image

💡 Additional Info

Notice on this line: var currentTime = ytPlayer.getCurrentTime() - 5; I add -5 as that way as I am watching video and like a part it will actually set the timestamp to 5 seconds earlier which gives me a couple seconds to activate the smart block and then make sure I don't have the time stamp start too late. Gives a little leeway into the part I want to mark.

If you are having any issues with this SmartBlock, make sure that you paste the JavaScript block as plain text using (on Windows) Ctrl + Shift + V so that the "soft line breaks" are preserved and the entire JavaScript is pasted into a single block in Roam. This means you must copy/paste the JavaScript block separate from the title/parent block. See the GIF below.

eE2NOolazM

GitMurf commented 3 years ago

Added a button to add the timestamps each time. Also added another small SB that converts a youtube link into the roam format youtube embed and auto indents underneath it the youtube timestamp button.

HERE IS A DEMO (click the GIF to start it over)

youtube timestamp embed

youtube timestamp button2

GitMurf commented 3 years ago

By Abhay:

cc: <@U01147Z3CMQ> - just something to watch out with the new YT timestamps JS. If someone changes the name they will need to update the button View in Slack

GitMurf commented 3 years ago

<@U013S9LL1FA> yep this is due to the "recurssive" nature / ability of smartblocks being able to call each other and itself via buttons. Remember the downsides I mentioned to you about making everything into one single SB as opposed to breaking them up into chunks :wink: hehe

https://roamresearch.slack.com/archives/CN10T100K/p1607972028263200?thread_ts=1607091041.208200&amp;cid=CN10T100K View in Slack

GitMurf commented 3 years ago

But actually <@U013S9LL1FA> this gives me an idea... you can access the name/title of the smartblock I believe, right <@U016YEJAKT4>? So when I build out the buttons, I would use the actual name of the smartblock so that it would be "dynamic" I believe so that you can change it to whatever you want. If this works it probably would be a best practice. Because I totally understand why folks would want to change the names of their SB to their liking instead of just being stuck with whatever the creator uses :slightly_smiling_face: View in Slack

GitMurf commented 3 years ago

CSS by Abhay:

Of course! They follow my themeset too! https://github.com/abhayprasanna/abhayprasanna.github.io/blob/master/optional.css

/* CCC's YT Timestamps JS customization */

.timestamp-control {
  color: var(--icons);
  margin-top: 3px;
  border: none;
  transition   : color 0.3s ease, border 0.3s ease;
}
.timestamp-control:hover {
  color: var(--icons-hover);
  transition   : color 0.3s ease, border 0.3s ease;
}

View in Slack

JimmyLv commented 3 years ago

@GitMurf @roamhacker hi~ anyway to add a keyboard shortcut for clicking the Add Timestamp button to generate timestrap directly?

agoodbear commented 3 years ago

By Abhay:

cc: <@U01147Z3CMQ> - just something to watch out with the new YT timestamps JS. If someone changes the name they will need to update the button View in Slack

How can I change the 『Add Stamp』button background color?I use the dark mode in roam,therefore the background color let this 『Add Stamp』not obviously~~~

CleanShot 2020-12-17 at 11 44 59@2x
abhayprasanna commented 3 years ago

Here is a simple SmartBlock add-on for this that will set up the following template for you if you have a YouTube URL copied into your clipboard.

image

agoodbear commented 3 years ago

Something wrong with this js code? When type a youtube link,then initiate the Smartblock->Always showed as below:

https://user-images.githubusercontent.com/71975781/103166960-0f8fa880-4862-11eb-9d72-6110d1235d4e.mp4

Does somebody had the same problem and how to solve it?

eyangs commented 3 years ago

Something wrong with this js code? When type a youtube link,then initiate the Smartblock->Always showed as below:

CleanShot.2020-12-27.at.16.37.46.mp4 Does somebody had the same problem and how to solve it?

same error with agoodbear!

Yulin-Rog commented 3 years ago

Screen Shot 2021-01-10 at 11 03 01 AM Hi all! I'm encountering a problem like this (i keep pressing the "timestamp" button, but it won't trigger anything or make a timestamp but showing up with a this code), anyone meets a similar situation or knows how to solve it? Many thx in advance 🥰

geekhuashan commented 3 years ago

knows how to solve it? Many thx in advan

I was also encountered this problem, how to fix the problem

growingtreesss commented 3 years ago

hi, I tried many youtube links, they didn't work. it just indicates"is not a valid youtube url", does anybody have the same problem?

abhayprasanna commented 3 years ago

Everyone, you have to have @c3founder's YT timestamps script for any of this to work in the first place. And since he has updated his extension to have a keyboard shortcut to add timestamps, you don't even need this SmartBlock anymore. https://c3founder.github.io/Roam-Enhancement/

natterstefan commented 3 years ago

Thanks for making me aware of that change, @abhayprasanna. Works like a charm now!