mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
Set user-agent for invidious.snopyta ID
This commit is contained in:
parent
c419aa90da
commit
98ee77def4
5 changed files with 21 additions and 6 deletions
|
|
@ -39,7 +39,7 @@ function lengthSecondsToLengthText(seconds) {
|
|||
*/
|
||||
function normaliseVideoInfo(video) {
|
||||
if (!video.second__lengthText && video.lengthSeconds > 0) {
|
||||
video.second__lengthText = converters.lengthSecondsToLengthText(video.lengthSeconds)
|
||||
video.second__lengthText = lengthSecondsToLengthText(video.lengthSeconds)
|
||||
}
|
||||
if (!video.second__lengthText && video.lengthSeconds === 0) {
|
||||
video.second__lengthText = "LIVE"
|
||||
|
|
|
|||
11
utils/request.js
Normal file
11
utils/request.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
const fetch = require("node-fetch")
|
||||
|
||||
function request(url, options = {}) {
|
||||
if (!options.headers) options.headers = {}
|
||||
options.headers = {
|
||||
"user-agent": "CloudTubeBackend/1.0"
|
||||
}
|
||||
return fetch(url, options)
|
||||
}
|
||||
|
||||
module.exports.request = request
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
const fetch = require("node-fetch")
|
||||
const {request} = require("./request")
|
||||
const db = require("./db")
|
||||
|
||||
async function fetchChannel(ucid, instance) {
|
||||
if (!instance) throw new Error("No instance parameter provided")
|
||||
// fetch
|
||||
const channel = await fetch(`${instance}/api/v1/channels/${ucid}`).then(res => res.json())
|
||||
const channel = await request(`${instance}/api/v1/channels/${ucid}`).then(res => res.json())
|
||||
// update database
|
||||
const bestIcon = channel.authorThumbnails.slice(-1)[0]
|
||||
const iconURL = bestIcon ? bestIcon.url : null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue