-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Move invidious out of stores #3045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
FreeTubeBot
merged 7 commits into
FreeTubeApp:development
from
ChunkyProgrammer:move-invidious-out-of-stores
Jan 12, 2023
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5b8ab1e
move invidious out of stores
ChunkyProgrammer dc791ad
fix getting more replies & local api fallback for comments
ChunkyProgrammer 4938baf
throw error if error message found in invidious response
ChunkyProgrammer 78017e8
fix issue with data setting
ChunkyProgrammer 45ea1dc
fix issue with replacing thumbnails
ChunkyProgrammer ce3d099
add bank line, remove slash
ChunkyProgrammer cf1d0ff
Apply suggestions from code review
ChunkyProgrammer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
move invidious out of stores
- Loading branch information
commit 5b8ab1ecb85421977289d19036609ef8180a2651
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import store from '../../store/index' | ||
| import { stripHTML, toLocalePublicationString } from '../utils' | ||
| import autolinker from 'autolinker' | ||
|
|
||
| function getCurrentInstance() { | ||
| return store.getters.getCurrentInvidiousInstance | ||
| } | ||
|
|
||
| export function invidiousAPICall({ resource, id = '', params = {} }) { | ||
| return new Promise((resolve, reject) => { | ||
| const requestUrl = getCurrentInstance() + '/api/v1/' + resource + '/' + id + '?' + new URLSearchParams(params).toString() | ||
|
|
||
| fetch(requestUrl) | ||
| .then((response) => response.json()) | ||
| .then((json) => { | ||
| resolve(json) | ||
| }) | ||
| .catch((error) => { | ||
| console.error('Invidious API error', requestUrl, error) | ||
| reject(error) | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| export async function invidiousGetChannelInfo(channelId) { | ||
| return new Promise((resolve, reject) => { | ||
| invidiousAPICall({ | ||
| resource: 'channels', | ||
| id: channelId, | ||
| }).then(response => { | ||
| resolve(response) | ||
| }).catch(xhr => { | ||
| console.error(xhr) | ||
| reject(xhr) | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| export async function invidiousGetPlaylistInfo(playlistId) { | ||
| const payload = { | ||
| resource: 'playlists', | ||
| id: playlistId | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| invidiousAPICall(payload).then((response) => { | ||
| resolve(response) | ||
| }).catch((xhr) => { | ||
| console.error(xhr) | ||
| reject(xhr) | ||
| }) | ||
| }) | ||
ChunkyProgrammer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| export async function invidiousGetVideoInformation(videoId) { | ||
| return new Promise((resolve, reject) => { | ||
| invidiousAPICall({ resource: 'videos', id: videoId }).then((response) => { | ||
| resolve(response) | ||
| }).catch((xhr) => { | ||
| console.error(xhr) | ||
| reject(xhr) | ||
| }) | ||
| }) | ||
ChunkyProgrammer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| export async function invidiousGetComments({ id, nextPageToken = '', sortNewest = true }) { | ||
| const payload = { | ||
| resource: 'comments', | ||
| id: id, | ||
| params: { | ||
| continuation: nextPageToken ?? '', | ||
| sort_by: sortNewest ? 'new' : 'top' | ||
| } | ||
| } | ||
| const response = await invidiousAPICall(payload) | ||
|
|
||
| const commentData = parseInvidiousCommentData(response) | ||
|
|
||
| return { response, commentData } | ||
| } | ||
|
|
||
| export async function invidiousGetCommentReplies({ id, replyContinuation }) { | ||
| const payload = { | ||
| resource: 'comments', | ||
| id: id, | ||
| params: { | ||
| continuation: replyContinuation | ||
| } | ||
| } | ||
|
|
||
| const response = await invidiousAPICall(payload) | ||
| return parseInvidiousCommentData(response) | ||
| } | ||
|
|
||
| function parseInvidiousCommentData(comments) { | ||
| return comments.map((comment) => { | ||
| comment.showReplies = false | ||
| comment.authorLink = comment.authorId | ||
| comment.authorThumb = comment.authorThumbnails[1].url.replace('https://yt3.ggpht.com', `${getCurrentInstance()}/ggpht/`) | ||
| comment.likes = comment.likeCount | ||
| comment.text = autolinker.link(stripHTML(comment.content)) | ||
| comment.dataType = 'invidious' | ||
| comment.isOwner = comment.authorIsChannelOwner | ||
| comment.numReplies = comment.replies?.replyCount ?? 0 | ||
| comment.replyContinuation = comment.replies?.continuation ?? '' | ||
| comment.isHearted = comment.creatorHeart !== undefined | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added support for hearted comments |
||
| comment.replies = [] | ||
| comment.time = toLocalePublicationString({ | ||
| publishText: comment.publishedText | ||
| }) | ||
|
|
||
| return comment | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.