mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 00:59:28 +01:00
use consistent user agent for requests
This commit is contained in:
parent
51f79ac8ad
commit
eb578fa5e6
@ -1,4 +1,5 @@
|
||||
import { Song } from '@app/models/music'
|
||||
import userAgent from '@app/util/userAgent'
|
||||
import { GetState, SetState } from 'zustand'
|
||||
import { Store } from './store'
|
||||
import { TrackExt } from './trackplayer'
|
||||
@ -29,6 +30,7 @@ export const createTrackPlayerMapSlice = (set: SetState<Store>, get: GetState<St
|
||||
artist: song.artist || 'Unknown Artist',
|
||||
album: song.album || 'Unknown Album',
|
||||
url: song.streamUri,
|
||||
userAgent,
|
||||
artwork,
|
||||
coverArt: song.coverArt,
|
||||
duration: song.duration,
|
||||
|
||||
@ -34,6 +34,7 @@ import {
|
||||
SubsonicResponse,
|
||||
} from '@app/subsonic/responses'
|
||||
import toast from '@app/util/toast'
|
||||
import userAgent from '@app/util/userAgent'
|
||||
import { DOMParser } from 'xmldom'
|
||||
|
||||
export class SubsonicApiError extends Error {
|
||||
@ -85,7 +86,9 @@ export class SubsonicApiClient {
|
||||
let text: string
|
||||
|
||||
try {
|
||||
const response = await fetch(this.buildUrl(method, params))
|
||||
const response = await fetch(this.buildUrl(method, params), {
|
||||
headers: { 'User-Agent': userAgent },
|
||||
})
|
||||
text = await response.text()
|
||||
} catch (err) {
|
||||
toast(`Network error: ${this.address}`)
|
||||
|
||||
3
app/util/userAgent.ts
Normal file
3
app/util/userAgent.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { Platform } from 'react-native'
|
||||
|
||||
export default `subtracks/${Platform.OS}`
|
||||
Loading…
x
Reference in New Issue
Block a user