[solution included] Youtube channels with /c/ChannelName URL format not handled
karimmorta opened this issue ยท 4 comments
Hi,
I tried to use the package with this type of URL : https://www.youtube.com/c/SoundofArman/
But I get Unable to find a id in https://www.youtube.com/c/SoundofArman
After research I saw it's possible to have the channel ID from the HTML source of a youtube channel page so I implemented this in my app (removed some parts of my code for clarity). I'm not a javascript expert so any feedback is appreciated :
var ytpl = require('ytpl');
const fs = require('fs');
const cheerio = require('cheerio');
const got = require('got');
exports.handler = async event => {
var channelUrl = event.queryStringParameters.channel_url
const validUrl = ytpl.validateURL(channelUrl)
if (!validUrl) {
var newChannelUrl = got(channelUrl).then(response => {
const $ = cheerio.load(response.body);
var link = $('link[title="RSS"]').prop('href');
var url = new URL(link);
var channelId = url.searchParams.get("channel_id");
return channelId
}
}
Would be nice to implement a similar solution in the package natively.
we have sth quite similar implemented to resolve users into channels
should be a fast adjustment ๐
your code looks fine
i am trying to keep ytdls dependencies low, thou
that's why i always hesitated to use sth like cheerio
Unfortunately that involves a Regex so I'm out sorry ๐
Not related, but one small detail, is it possible to add the description to the video in buildVideoObject ? I think it's an important information to display in a UI.
I'm willing to PR if needed :)
Cheers
for now i implemented the changes in the rework-branch
can be installed via npm or you wait until the end of the month when i'm planning to bring the rework to master
๐ done with the merge of rework