Replace comment logic with new scraper (Still not working yet)

This commit is contained in:
Preston 2020-09-20 21:59:59 -04:00
parent 3f7af07142
commit 8d22aaad34
4 changed files with 77 additions and 88 deletions

91
package-lock.json generated
View File

@ -3459,9 +3459,9 @@
"dev": true
},
"archiver": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/archiver/-/archiver-5.0.0.tgz",
"integrity": "sha512-AEWhJz6Yi6hWtN1Sqy/H4sZo/lLMJ/NftXxGaDy/TnOMmmjsRaZc/Ts+U4BsPoBQkuunTN6t8hk7iU9A+HBxLw==",
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/archiver/-/archiver-5.0.2.tgz",
"integrity": "sha512-Tq3yV/T4wxBsD2Wign8W9VQKhaUxzzRmjEiSoOK0SLqPgDP/N1TKdYyBeIEu56T4I9iO4fKTTR0mN9NWkBA0sg==",
"dev": true,
"requires": {
"archiver-utils": "^2.1.0",
@ -3469,7 +3469,7 @@
"buffer-crc32": "^0.2.1",
"readable-stream": "^3.6.0",
"readdir-glob": "^1.0.0",
"tar-stream": "^2.1.2",
"tar-stream": "^2.1.4",
"zip-stream": "^4.0.0"
},
"dependencies": {
@ -7102,16 +7102,16 @@
}
},
"electron-builder-squirrel-windows": {
"version": "22.8.1",
"resolved": "https://registry.npmjs.org/electron-builder-squirrel-windows/-/electron-builder-squirrel-windows-22.8.1.tgz",
"integrity": "sha512-iNUny04kHMUVJ3JW+I3k9sS4MtnunftQN1rGTU2EsqQhTZ9Dl4VxSQKp8riQHF3hNCHqN43VGbtE2IB/bqXnpA==",
"version": "22.9.0",
"resolved": "https://registry.npmjs.org/electron-builder-squirrel-windows/-/electron-builder-squirrel-windows-22.9.0.tgz",
"integrity": "sha512-+LO8FTrWUyPOVcGpcgs3Ko+Qe7aj9Iv6oBPhwgUq6GDqd/VHHUBqLshkmnAoZXCPbUXdcJ7eFg1N+fg0oIQ1+A==",
"dev": true,
"requires": {
"7zip-bin": "~5.0.3",
"app-builder-lib": "22.8.1",
"archiver": "^5.0.0",
"app-builder-lib": "22.9.0",
"archiver": "^5.0.2",
"bluebird-lst": "^1.0.9",
"builder-util": "22.8.1",
"builder-util": "22.9.0",
"fs-extra": "^9.0.1",
"sanitize-filename": "^1.6.3"
},
@ -7126,28 +7126,22 @@
"color-convert": "^2.0.1"
}
},
"app-builder-bin": {
"version": "3.5.10",
"resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-3.5.10.tgz",
"integrity": "sha512-Jd+GW68lR0NeetgZDo47PdWBEPdnD+p0jEa7XaxjRC8u6Oo/wgJsfKUkORRgr2NpkD19IFKN50P6JYy04XHFLQ==",
"dev": true
},
"app-builder-lib": {
"version": "22.8.1",
"resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-22.8.1.tgz",
"integrity": "sha512-D/ac1+vuGIAAwEeTtXl8b+qWl7Gz/IQatFyzYl2ocag/7N8LqUjKzZFJJISQPWt6PFDPDH0oCj8/GMh63aV0yw==",
"version": "22.9.0",
"resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-22.9.0.tgz",
"integrity": "sha512-MKgWGUMPYJFn7GG/ta5Qw79zNvtRCWodH2xICK9l2NpPtWmr+9LoTcRk90rI4m0RjKR5GoSoOytEAok91YrFyw==",
"dev": true,
"requires": {
"7zip-bin": "~5.0.3",
"@develar/schema-utils": "~2.6.5",
"async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.9",
"builder-util": "22.8.1",
"builder-util": "22.9.0",
"builder-util-runtime": "8.7.2",
"chromium-pickle-js": "^0.2.0",
"debug": "^4.2.0",
"ejs": "^3.1.3",
"electron-publish": "22.8.1",
"ejs": "^3.1.5",
"electron-publish": "22.9.0",
"fs-extra": "^9.0.1",
"hosted-git-info": "^3.0.5",
"is-ci": "^2.0.0",
@ -7163,9 +7157,9 @@
}
},
"builder-util": {
"version": "22.8.1",
"resolved": "https://registry.npmjs.org/builder-util/-/builder-util-22.8.1.tgz",
"integrity": "sha512-LZG+E1xszMdut5hL5h7RkJQ7yOsQqdhJYgn1wvOP7MmF3MoUPRNDiRodLpYiWlaqZmgYhcfaipR/Mb8F/RqK8w==",
"version": "22.9.0",
"resolved": "https://registry.npmjs.org/builder-util/-/builder-util-22.9.0.tgz",
"integrity": "sha512-ySOKJ8E/Jrhe5VdfzTny0imXhRd5ql5fUDlt/AuPZeSZiZFkutEPwjV2akEDGaQXgMxWeGcb4AtuL4DrdOgBhw==",
"dev": true,
"requires": {
"7zip-bin": "~5.0.3",
@ -7218,15 +7212,24 @@
"ms": "2.1.2"
}
},
"ejs": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.5.tgz",
"integrity": "sha512-dldq3ZfFtgVTJMLjOe+/3sROTzALlL9E34V4/sDtUd/KlBSS0s6U1/+WPE1B4sj9CXHJpL1M6rhNJnc9Wbal9w==",
"dev": true,
"requires": {
"jake": "^10.6.1"
}
},
"electron-publish": {
"version": "22.8.1",
"resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.8.1.tgz",
"integrity": "sha512-zqI66vl7j1CJZJ60J+1ez1tQNQeuqVspW44JvYDa5kZbM5wSFDAJFMK9RWHOqRF1Ezd4LDeiBa4aeTOwOt9syA==",
"version": "22.9.0",
"resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.9.0.tgz",
"integrity": "sha512-CItOeTNtezLHuGWDL+7y3ZzRIWd/fcMzJLaoXQfSGv7dCdZPkPmq0AS2BAs+2hcsrx+755SBFbEqqXKhv7dSUw==",
"dev": true,
"requires": {
"@types/fs-extra": "^9.0.1",
"bluebird-lst": "^1.0.9",
"builder-util": "22.8.1",
"builder-util": "22.9.0",
"builder-util-runtime": "8.7.2",
"chalk": "^4.1.0",
"fs-extra": "^9.0.1",
@ -7258,16 +7261,6 @@
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"js-yaml": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz",
"integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"jsonfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz",
@ -7313,9 +7306,9 @@
}
},
"supports-color": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
"integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
@ -18080,12 +18073,12 @@
}
},
"tar-stream": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.3.tgz",
"integrity": "sha512-Z9yri56Dih8IaK8gncVPx4Wqt86NDmQTSh49XLZgjWpGZL9GK9HKParS2scqHCC4w6X9Gh2jwaU45V47XTKwVA==",
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.4.tgz",
"integrity": "sha512-o3pS2zlG4gxr67GmFYBLlq+dM8gyRGUOvsrHclSkvtVtQbjV0s/+ZE8OpICbaj8clrX3tjeHngYGP7rweaBnuw==",
"dev": true,
"requires": {
"bl": "^4.0.1",
"bl": "^4.0.3",
"end-of-stream": "^1.4.1",
"fs-constants": "^1.0.0",
"inherits": "^2.0.3",
@ -20446,9 +20439,9 @@
}
},
"yt-comment-scraper": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/yt-comment-scraper/-/yt-comment-scraper-1.0.0.tgz",
"integrity": "sha512-xcHKuQip0/YPTRD1uKpoUG3qIxGPVrHbUpfej3FxlYjyS5GtxcNI/VfSW1nQHRK+9omVFsLagqj2v5lDXosA8A==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/yt-comment-scraper/-/yt-comment-scraper-1.1.0.tgz",
"integrity": "sha512-WLEhIWvVy/5AjxNCOtZb5RuZYcwWhUU/b6eduVakUip3EONsGFQI8u4BcEknoxIZirb7yQYasq0Llhv0xqKkig==",
"requires": {
"axios": "^0.19.2",
"html2json": "^1.0.2"

View File

@ -45,7 +45,7 @@
"youtube-comments-task": "^1.3.15",
"youtube-suggest": "^1.1.0",
"yt-channel-info": "^1.1.1",
"yt-comment-scraper": "^1.0.0",
"yt-comment-scraper": "^1.1.0",
"yt-dash-manifest-generator": "^1.1.0",
"yt-trending-scraper": "^1.0.3",
"yt-xml2vtt": "^1.1.2",
@ -70,7 +70,7 @@
"devtron": "^1.4.0",
"electron": "^10.1.2",
"electron-builder": "^22.8.1",
"electron-builder-squirrel-windows": "^22.8.1",
"electron-builder-squirrel-windows": "^22.9.0",
"electron-debug": "^3.1.0",
"electron-rebuild": "^2.0.3",
"eslint": "^7.9.0",

View File

@ -1,4 +1,5 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtInput from '../ft-input/ft-input.vue'
import FtSearchFilters from '../ft-search-filters/ft-search-filters.vue'
import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue'
@ -148,12 +149,9 @@ export default Vue.extend({
}
}
this.$store
.dispatch('invidiousAPICall', searchPayload)
.then((results) => {
this.$store.dispatch('invidiousAPICall', searchPayload).then((results) => {
this.searchSuggestionsDataList = results.suggestions
})
.error((err) => {
}).catch((err) => {
console.log(err)
if (this.backendFallback) {
console.log(

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import { mapActions } from 'vuex'
import FtCard from '../ft-card/ft-card.vue'
import FtLoader from '../../components/ft-loader/ft-loader.vue'
import ytct from 'youtube-comments-task'
import ytcs from 'yt-comment-scraper'
export default Vue.extend({
name: 'WatchVideoComments',
@ -67,16 +67,28 @@ export default Vue.extend({
getCommentDataLocal: function () {
console.log('Getting comment data please wait..')
ytct(this.id, this.nextPageToken).fork(e => {
ytcs.scrape_next_page_youtube_comments(this.id).then((response) => {
console.log(response)
const commentData = response.comments.map((comment) => {
comment.showReplies = false
comment.dataType = 'local'
return comment
})
console.log(commentData)
this.commentData = this.commentData.concat(commentData)
this.isLoading = false
this.showComments = true
}).catch((err) => {
console.log(err)
const errorMessage = this.$t('Local API Error (Click to copy)')
this.showToast({
message: `${errorMessage}: ${e.message}`,
message: `${errorMessage}: ${err}`,
time: 10000,
action: () => {
navigator.clipboard.writeText(e.message)
navigator.clipboard.writeText(err)
}
})
console.error('ERROR', e)
if (this.backendFallback && this.backendPreference === 'local') {
this.showToast({
message: this.$t('Falling back to Invidious API')
@ -85,21 +97,6 @@ export default Vue.extend({
} else {
this.isLoading = false
}
},
p => {
const commentData = p.comments.map((comment) => {
comment.showReplies = false
comment.authorId = comment.authorLink.replace('/channel/', '')
comment.authorId = comment.authorId.replace('/user/', '')
comment.dataType = 'local'
return comment
})
console.log(commentData)
this.commentData = this.commentData.concat(commentData)
this.nextPageToken = p.nextPageToken
this.isLoading = false
this.showComments = true
})
},
@ -112,7 +109,7 @@ export default Vue.extend({
}
}
this.$store.dispatch('invidiousAPICall', payload).then((response) => {
this.invidiousAPICall(payload).then((response) => {
console.log(response)
const commentData = response.comments.map((comment) => {
@ -154,7 +151,7 @@ export default Vue.extend({
})
if (this.backendFallback && this.backendPreference === 'invidious') {
this.showToast({
message: this.$t('Falling back to Local API')
message: this.$t('Falling back to local API')
})
this.getCommentDataLocal()
} else {
@ -212,7 +209,8 @@ export default Vue.extend({
},
...mapActions([
'showToast'
'showToast',
'invidiousAPICall'
])
}
})