Update local channel scraper
This commit is contained in:
parent
892bb96611
commit
c89f12f04c
|
@ -20417,9 +20417,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"yt-channel-info": {
|
"yt-channel-info": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/yt-channel-info/-/yt-channel-info-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/yt-channel-info/-/yt-channel-info-1.1.2.tgz",
|
||||||
"integrity": "sha512-cc//j7sDphcp95SZXs1IEvqSaAkYvtB1qFILvAaeqAQnMCIokbN71S4dgEmtBfVAOnbSfKgf1GagL2e4A63pOQ==",
|
"integrity": "sha512-H+NnGItGWZutCEGHTr7OZrFqZSKwujJYoJD5js9XhVMe8Nzk3/ymF9YqB5sH+jaxFu9WOqz3q6QW8idCjqucIQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"querystring": "^0.2.0"
|
"querystring": "^0.2.0"
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
"youtube-comments-fetch": "^1.0.1",
|
"youtube-comments-fetch": "^1.0.1",
|
||||||
"youtube-comments-task": "^1.3.15",
|
"youtube-comments-task": "^1.3.15",
|
||||||
"youtube-suggest": "^1.1.0",
|
"youtube-suggest": "^1.1.0",
|
||||||
"yt-channel-info": "^1.1.1",
|
"yt-channel-info": "^1.1.2",
|
||||||
"yt-dash-manifest-generator": "^1.1.0",
|
"yt-dash-manifest-generator": "^1.1.0",
|
||||||
"yt-trending-scraper": "^1.0.3",
|
"yt-trending-scraper": "^1.0.3",
|
||||||
"yt-xml2vtt": "^1.1.2",
|
"yt-xml2vtt": "^1.1.2",
|
||||||
|
|
|
@ -156,15 +156,15 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (!this.usingElectron || this.backendPreference === 'invidious') {
|
if (!this.usingElectron || this.backendPreference === 'invidious') {
|
||||||
if (this.useRssFeeds) {
|
if (this.useRssFeeds) {
|
||||||
videos = await this.getChannelVideosInvidiousRSS(channel.id)
|
videos = await this.getChannelVideosInvidiousRSS(channel)
|
||||||
} else {
|
} else {
|
||||||
videos = await this.getChannelVideosInvidiousScraper(channel.id)
|
videos = await this.getChannelVideosInvidiousScraper(channel)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.useRssFeeds) {
|
if (this.useRssFeeds) {
|
||||||
videos = await this.getChannelVideosLocalRSS(channel.id)
|
videos = await this.getChannelVideosLocalRSS(channel)
|
||||||
} else {
|
} else {
|
||||||
videos = await this.getChannelVideosLocalScraper(channel.id)
|
videos = await this.getChannelVideosLocalScraper(channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,9 +205,9 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getChannelVideosLocalScraper: function (channelId, failedAttempts = 0) {
|
getChannelVideosLocalScraper: function (channel, failedAttempts = 0) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ytch.getChannelVideos(channelId, 'latest').then(async (response) => {
|
ytch.getChannelVideos(channel.id, 'latest').then(async (response) => {
|
||||||
const videos = await Promise.all(response.items.map(async (video) => {
|
const videos = await Promise.all(response.items.map(async (video) => {
|
||||||
if (video.liveNow) {
|
if (video.liveNow) {
|
||||||
video.publishedDate = new Date().getTime()
|
video.publishedDate = new Date().getTime()
|
||||||
|
@ -230,20 +230,20 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
switch (failedAttempts) {
|
switch (failedAttempts) {
|
||||||
case 0:
|
case 0:
|
||||||
resolve(this.getChannelVideosLocalRSS(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosLocalRSS(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
case 1:
|
case 1:
|
||||||
if (this.backendFallback) {
|
if (this.backendFallback) {
|
||||||
this.showToast({
|
this.showToast({
|
||||||
message: this.$t('Falling back to the Invidious API')
|
message: this.$t('Falling back to Invidious API')
|
||||||
})
|
})
|
||||||
resolve(this.getChannelVideosInvidiousScraper(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosInvidiousScraper(channel, failedAttempts + 1))
|
||||||
} else {
|
} else {
|
||||||
resolve([])
|
resolve([])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
resolve(this.getChannelVideosLocalRSS(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosLocalRSS(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
resolve([])
|
resolve([])
|
||||||
|
@ -252,14 +252,14 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getChannelVideosLocalRSS: function (channelId, failedAttempts = 0) {
|
getChannelVideosLocalRSS: function (channel, failedAttempts = 0) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const parser = new Parser()
|
const parser = new Parser()
|
||||||
const feedUrl = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`
|
const feedUrl = `https://www.youtube.com/feeds/videos.xml?channel_id=${channel.id}`
|
||||||
|
|
||||||
parser.parseURL(feedUrl).then(async (feed) => {
|
parser.parseURL(feedUrl).then(async (feed) => {
|
||||||
const items = await Promise.all(feed.items.map((video) => {
|
const items = await Promise.all(feed.items.map((video) => {
|
||||||
video.authorId = channelId
|
video.authorId = channel.id
|
||||||
video.videoId = video.id.replace('yt:video:', '')
|
video.videoId = video.id.replace('yt:video:', '')
|
||||||
video.type = 'video'
|
video.type = 'video'
|
||||||
video.lengthSeconds = '0:00'
|
video.lengthSeconds = '0:00'
|
||||||
|
@ -289,20 +289,20 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
switch (failedAttempts) {
|
switch (failedAttempts) {
|
||||||
case 0:
|
case 0:
|
||||||
resolve(this.getChannelVideosLocalScraper(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosLocalScraper(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
case 1:
|
case 1:
|
||||||
if (this.backendFallback) {
|
if (this.backendFallback) {
|
||||||
this.showToast({
|
this.showToast({
|
||||||
message: this.$t('Falling back to the Invidious API')
|
message: this.$t('Falling back to Invidious API')
|
||||||
})
|
})
|
||||||
resolve(this.getChannelVideosInvidiousRSS(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosInvidiousRSS(channel, failedAttempts + 1))
|
||||||
} else {
|
} else {
|
||||||
resolve([])
|
resolve([])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
resolve(this.getChannelVideosLocalScraper(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosLocalScraper(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
resolve([])
|
resolve([])
|
||||||
|
@ -311,11 +311,11 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getChannelVideosInvidiousScraper: function (channelId, failedAttempts = 0) {
|
getChannelVideosInvidiousScraper: function (channel, failedAttempts = 0) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const subscriptionsPayload = {
|
const subscriptionsPayload = {
|
||||||
resource: 'channels/latest',
|
resource: 'channels/latest',
|
||||||
id: channelId,
|
id: channel.id,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,20 +336,20 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
switch (failedAttempts) {
|
switch (failedAttempts) {
|
||||||
case 0:
|
case 0:
|
||||||
resolve(this.getChannelVideosInvidiousRSS(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosInvidiousRSS(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
case 1:
|
case 1:
|
||||||
if (this.backendFallback) {
|
if (this.backendFallback) {
|
||||||
this.showToast({
|
this.showToast({
|
||||||
message: this.$t('Falling back to the local API')
|
message: this.$t('Falling back to the local API')
|
||||||
})
|
})
|
||||||
resolve(this.getChannelVideosLocalScraper(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosLocalScraper(channel, failedAttempts + 1))
|
||||||
} else {
|
} else {
|
||||||
resolve([])
|
resolve([])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
resolve(this.getChannelVideosInvidiousRSS(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosInvidiousRSS(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
resolve([])
|
resolve([])
|
||||||
|
@ -358,14 +358,14 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getChannelVideosInvidiousRSS: function (channelId, failedAttempts = 0) {
|
getChannelVideosInvidiousRSS: function (channel, failedAttempts = 0) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const parser = new Parser()
|
const parser = new Parser()
|
||||||
const feedUrl = `${this.invidiousInstance}/feed/channel/${channelId}`
|
const feedUrl = `${this.invidiousInstance}/feed/channel/${channel.id}`
|
||||||
|
|
||||||
parser.parseURL(feedUrl).then(async (feed) => {
|
parser.parseURL(feedUrl).then(async (feed) => {
|
||||||
resolve(await Promise.all(feed.items.map((video) => {
|
resolve(await Promise.all(feed.items.map((video) => {
|
||||||
video.authorId = channelId
|
video.authorId = channel.id
|
||||||
video.videoId = video.id.replace('yt:video:', '')
|
video.videoId = video.id.replace('yt:video:', '')
|
||||||
video.type = 'video'
|
video.type = 'video'
|
||||||
video.publishedDate = new Date(video.pubDate)
|
video.publishedDate = new Date(video.pubDate)
|
||||||
|
@ -387,20 +387,20 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
switch (failedAttempts) {
|
switch (failedAttempts) {
|
||||||
case 0:
|
case 0:
|
||||||
resolve(this.getChannelVideosInvidiousScraper(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosInvidiousScraper(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
case 1:
|
case 1:
|
||||||
if (this.backendFallback) {
|
if (this.backendFallback) {
|
||||||
this.showToast({
|
this.showToast({
|
||||||
message: this.$t('Falling back to the local API')
|
message: this.$t('Falling back to the local API')
|
||||||
})
|
})
|
||||||
resolve(this.getChannelVideosLocalRSS(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosLocalRSS(channel, failedAttempts + 1))
|
||||||
} else {
|
} else {
|
||||||
resolve([])
|
resolve([])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
resolve(this.getChannelVideosInvidiousScraper(channelId, failedAttempts + 1))
|
resolve(this.getChannelVideosInvidiousScraper(channel, failedAttempts + 1))
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
resolve([])
|
resolve([])
|
||||||
|
|
Loading…
Reference in New Issue