mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 09:09:29 +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 { Song } from '@app/models/music'
|
||||||
|
import userAgent from '@app/util/userAgent'
|
||||||
import { GetState, SetState } from 'zustand'
|
import { GetState, SetState } from 'zustand'
|
||||||
import { Store } from './store'
|
import { Store } from './store'
|
||||||
import { TrackExt } from './trackplayer'
|
import { TrackExt } from './trackplayer'
|
||||||
@ -29,6 +30,7 @@ export const createTrackPlayerMapSlice = (set: SetState<Store>, get: GetState<St
|
|||||||
artist: song.artist || 'Unknown Artist',
|
artist: song.artist || 'Unknown Artist',
|
||||||
album: song.album || 'Unknown Album',
|
album: song.album || 'Unknown Album',
|
||||||
url: song.streamUri,
|
url: song.streamUri,
|
||||||
|
userAgent,
|
||||||
artwork,
|
artwork,
|
||||||
coverArt: song.coverArt,
|
coverArt: song.coverArt,
|
||||||
duration: song.duration,
|
duration: song.duration,
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import {
|
|||||||
SubsonicResponse,
|
SubsonicResponse,
|
||||||
} from '@app/subsonic/responses'
|
} from '@app/subsonic/responses'
|
||||||
import toast from '@app/util/toast'
|
import toast from '@app/util/toast'
|
||||||
|
import userAgent from '@app/util/userAgent'
|
||||||
import { DOMParser } from 'xmldom'
|
import { DOMParser } from 'xmldom'
|
||||||
|
|
||||||
export class SubsonicApiError extends Error {
|
export class SubsonicApiError extends Error {
|
||||||
@ -85,7 +86,9 @@ export class SubsonicApiClient {
|
|||||||
let text: string
|
let text: string
|
||||||
|
|
||||||
try {
|
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()
|
text = await response.text()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast(`Network error: ${this.address}`)
|
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