TheIconfactory / Tapestry

MIT License
110 stars 9 forks source link

Updates youtube plugin to be able to work out of the channel's url #6

Open Dudemullet opened 9 months ago

Dudemullet commented 9 months ago

Hi 👋

This PR updates the youtube plugin to be able to work out of a channels regular url. By regular I mean whatever you see when you click on their avatar or whenver you google something like "youtube The Iconfactory". This also updates this plugin's placeholder config to represent this change.

Some questions/suggestions after trying out the API:

gracjankn commented 8 months ago

I tried your version of the plugin in Tapestry Loom. When I enter the placeholder URL (https://www.youtube.com/@theiconfactory) and click Verify, I get the following error message:

TypeError: undefined is not an object (evaluating 'channelUrl.lastIndexOf')

The same happens when I try the version of the URL that uses the UUID of a channel instead of the nickname (https://www.youtube.com/channel/UC7zt-GmwdxyqgSwhKmhSniQ; also a valid URL for The Iconfactory channel).

Dudemullet commented 8 months ago

Weird, I had seen this error during development but it stopped happening to me. I'll code to handle this error and call setIdentifier(null) on error as other plugins seem to handle error/uknown scenarios.

As a sidenote, in my env both examples are working which is pretty cool because I hadn't tested your second example. Thanks @gracjankn 👍

Dudemullet commented 8 months ago

Ok so found an unexpected behavior that explains what's going on and why you were seeing that error @gracjankn. the identify method is being called when clicking the "Set Variables..." button. So if a previos value had been saved for site, a new HTTP Request is being sent with that value, before having the chance to update it.

Anyway, I added an Exception handler for that scenario.

gracjankn commented 8 months ago

I tested the updated version. It no longer throws an error when trying to save the variables, but it doesn't function correctly afterwards.

The source is named YouTube Channel (Unknown). When I click Load, it throws up the following error message:

YouTube Channel (Unknown) Error: Error: exception = unsupported URL

I tried both the URLs I mentioned previously.

Dudemullet commented 8 months ago

I can't reproduce this @gracjankn, given that some state is saved across setting different variables, have you tried resetting the variables?

There's a "Reset" button in the "Set Variables..." menu, ave you tried that? Also, maybe trying using both urls before reloading the plugin

Screenshot 2024-03-03 at 5 59 02 PM