Comments (7)
Could you give a small example of your code? I don't seem to understand the issue at hand.
In the image it shows a list of found track titles but then when you select a track the title is undefined?
from scraper.
That quite fast response, here is the line https://github.com/Ayeven/generic-bot/blob/c87589523aefc7b87c0a95959b51239285b89698/base/track.js#L86 which I can't extract info from url link. I console log it, return empty array. The music is correctly playing the right track, but title become undefined since empty array. This is the full repo link : https://github.com/Ayeven/generic-bot
from scraper.
This is expected behavior as this Scraper just replicates the search from YouTube and parses the response data, if you were to fill in an URL in YouTube search it might return the expected video or it might not...
const { Scraper } = require('@yimura/scraper');
const ytsr = new Scraper();
ytsr.search("keywords");
If YouTube doesn't return data for a link then we can't parse it, your code also seems incorrect as the return object for Scraper#search() is vastly different and doesn't contain the title property.
Example Return Object:
{
channels: [
{ ... }
],
playlists: [
{ ... }
],
streams: [
{ ... }
],
videos: [
{
description: String,
duration: Number,
uploaded: String,
views: Number,
channel: {
name: String,
link: String,
verified: Boolean
},
id: String,
link: String,
thumbnail: String,
title: String,
shareLink: String
}
]
}
from scraper.
if ((url.startsWith('https://www.youtube.com/')) || (url.startsWith('https://youtu.be')) || (url.startsWith('https://m.youtube.com'))) { const yt = await ytsr.search(url); console.log(yt); info = yt.videos[0].title ?? 'Unknown Track'; }
Yeah, found the issue now, sorry to bug you, must've been rushing reading the #readme.
Edit :
console.log :
https://youtu.be/FHr3g1c11yw { channels: [], playlists: [], streams: [], videos: [] }
TypeError: Cannot read property 'title' of undefined. still seem not able to capture the title from url link
from scraper.
Sometime it able to capture the title
from scraper.
This inconsistency comes down to YouTube themselves.
I'm unable to reproduce your issue, seems to do what it is supposed to...
https://runkit.com/embed/o1fw9ymgai9g
from scraper.
let info = ''; if ((url.startsWith('https://www.youtube.com/')) || (url.startsWith('https://youtu.be')) || (url.startsWith('https://m.youtube.com'))) { const yt = new Scraper(); const ytsr = await yt.search(id || url); info = ytsr.videos[0]?.title ?? 'Unknown Track'; } else if (url.startsWith('https://soundcloud.com/')) { const sc = await scdl.getInfo(url || id); info = sc.title; } else { info = 'Unknown Track'; }
Lmao, some solution for that inconsistency, so far it can capture it, well it is from the video id. I'll see if the issue persist
from scraper.
Related Issues (9)
- Set Accept-Language header HOT 1
- Allow providing video url directly HOT 1
- Unexpected token '.', but normal fix isnβt working HOT 1
- "TypeError: The "listener" argument must be of type Function. Received type object" when using with NextJS HOT 3
- Thumbnail picture is incorrectly formatted
- TypeError The "listener" argument must be of type function. Received an instance of Object HOT 8
- Thumbnail scrape issues HOT 3
- Unexpected token '.' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scraper.