mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-15 08:07:22 -05:00
remove testing file, bump version, update constants
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ node_modules
|
|||||||
!.env.example
|
!.env.example
|
||||||
/test.js
|
/test.js
|
||||||
/tmp
|
/tmp
|
||||||
|
/run.js
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lucida",
|
"name": "lucida",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"description": "A modular downloader tool",
|
"description": "A modular downloader tool",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
11
run.js
11
run.js
@@ -1,11 +0,0 @@
|
|||||||
import Lucida from './build/index.js';
|
|
||||||
import Soundcloud from './build/streamers/soundcloud/main.js'
|
|
||||||
|
|
||||||
const lucida = new Lucida({
|
|
||||||
modules: {
|
|
||||||
soundcloud: new Soundcloud({"oauthToken": "2-294707-1346470389-4thCm1p3QnA05"})
|
|
||||||
},
|
|
||||||
logins: {}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(await lucida.search("ram ranch"))
|
|
||||||
@@ -12,4 +12,4 @@ export const DEFAULT_HEADERS = {
|
|||||||
'User-Agent':
|
'User-Agent':
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36'
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36'
|
||||||
}
|
}
|
||||||
export const SC_VERSION = '1686222762'
|
export const SC_VERSION = '1712837702'
|
||||||
|
|||||||
@@ -38,16 +38,21 @@ export default class Soundcloud implements Streamer {
|
|||||||
hostnames = ['soundcloud.com', 'm.soundcloud.com', 'www.soundcloud.com']
|
hostnames = ['soundcloud.com', 'm.soundcloud.com', 'www.soundcloud.com']
|
||||||
oauthToken?: string
|
oauthToken?: string
|
||||||
constructor(options: SoundcloudOptions) {
|
constructor(options: SoundcloudOptions) {
|
||||||
this.oauthToken = options.oauthToken
|
this.oauthToken = options?.oauthToken
|
||||||
}
|
}
|
||||||
async search(query: string, limit = 20): Promise<SearchResults> {
|
async search(query: string, limit = 20): Promise<SearchResults> {
|
||||||
const client = await this.#getClient()
|
const client = await this.#getClient()
|
||||||
|
console.log(this.#formatURL(
|
||||||
|
`https://api-v2.soundcloud.com/search?q=${encodeURIComponent(
|
||||||
|
query
|
||||||
|
)}&offset=0&linked_partitioning=1&app_locale=en&limit=${limit}`,
|
||||||
|
client
|
||||||
|
), headers(this.oauthToken))
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
this.#formatURL(
|
this.#formatURL(
|
||||||
`https://api-v2.soundcloud.com/search?q=${encodeURIComponent(
|
`https://api-v2.soundcloud.com/search?q=${encodeURIComponent(
|
||||||
query
|
query
|
||||||
)}&app_locale=en&limit=${limit}`,
|
)}&offset=0&linked_partitioning=1&app_locale=en&limit=${limit}`,
|
||||||
client
|
client
|
||||||
),
|
),
|
||||||
{ method: 'get', headers: headers(this.oauthToken) }
|
{ method: 'get', headers: headers(this.oauthToken) }
|
||||||
@@ -57,7 +62,8 @@ export default class Soundcloud implements Streamer {
|
|||||||
try {
|
try {
|
||||||
throw new Error(JSON.parse(errMsg))
|
throw new Error(JSON.parse(errMsg))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(errMsg);
|
if (errMsg) throw new Error(errMsg)
|
||||||
|
else throw new Error('Soundcloud request failed.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user