remove testing file, bump version, update constants

This commit is contained in:
aria blue
2024-04-11 13:54:35 -04:00
parent 5768bf9127
commit f14ece0675
5 changed files with 14 additions and 18 deletions

View File

@@ -12,4 +12,4 @@ export const DEFAULT_HEADERS = {
'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'
}
export const SC_VERSION = '1686222762'
export const SC_VERSION = '1712837702'

View File

@@ -38,16 +38,21 @@ export default class Soundcloud implements Streamer {
hostnames = ['soundcloud.com', 'm.soundcloud.com', 'www.soundcloud.com']
oauthToken?: string
constructor(options: SoundcloudOptions) {
this.oauthToken = options.oauthToken
this.oauthToken = options?.oauthToken
}
async search(query: string, limit = 20): Promise<SearchResults> {
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(
this.#formatURL(
`https://api-v2.soundcloud.com/search?q=${encodeURIComponent(
query
)}&app_locale=en&limit=${limit}`,
)}&offset=0&linked_partitioning=1&app_locale=en&limit=${limit}`,
client
),
{ method: 'get', headers: headers(this.oauthToken) }
@@ -57,7 +62,8 @@ export default class Soundcloud implements Streamer {
try {
throw new Error(JSON.parse(errMsg))
} catch (error) {
throw new Error(errMsg);
if (errMsg) throw new Error(errMsg)
else throw new Error('Soundcloud request failed.')
}
}