@@ -9,7 +9,6 @@ import { DurationPrecision, FeatureQuality, type FeatureQualityMap } from '@/pro
99import type { PartialDate } from '@/utils/date.ts' ;
1010import { parseDuration } from '@/utils/time.ts' ;
1111import { ProviderError } from '@/utils/errors.ts' ;
12- import { getFromEnv } from '@/utils/config.ts' ;
1312import type {
1413 ArtistCreditName ,
1514 Artwork ,
@@ -22,10 +21,11 @@ import type {
2221 ReleaseGroupType ,
2322} from '@/harmonizer/types.ts' ;
2423import type { BugsAlbum , BugsArtist , BugsMultiResponse , BugsTrack } from './api_types.ts' ;
24+ import { getFromEnv } from '../../utils/config.ts' ;
2525
2626const IMAGE_BASE = 'https://image.bugsm.co.kr/album/images' ;
2727
28- const bugsDeviceId = getFromEnv ( 'HARMONY_BUGS_DEVICE_ID ' ) ?? 'harmony ';
28+ const bugsMobileClientSecret = getFromEnv ( 'HARMONY_BUGS_CLIENT_SECRET ' ) || ' ';
2929
3030export default class BugsProvider extends MetadataApiProvider {
3131 readonly name = 'Bugs!' ;
@@ -60,10 +60,6 @@ export default class BugsProvider extends MetadataApiProvider {
6060
6161 readonly apiBaseUrl = 'https://mapi.bugs.co.kr/music/5/multi/invoke/map' ;
6262
63- override get internalName ( ) : string {
64- return 'bugs' ;
65- }
66-
6763 constructUrl ( entity : EntityId ) : URL {
6864 return new URL ( [ entity . type , entity . id ] . join ( '/' ) , 'https://music.bugs.co.kr/' ) ;
6965 }
@@ -78,7 +74,6 @@ export default class BugsProvider extends MetadataApiProvider {
7874 { id : 'album' , args : { album_id : albumId , result_type : 'DETAIL' } } ,
7975 { id : 'album_track' , args : { album_id : albumId , result_type : 'LIST' } } ,
8076 ] ) ;
81- if ( bugsDeviceId ) apiUrl . searchParams . set ( 'device_id' , bugsDeviceId ) ;
8277 const accessToken = await this . cachedAccessToken ( this . requestAccessToken ) ;
8378 return this . fetchJSON < Data > ( apiUrl , {
8479 policy : { maxTimestamp : options . snapshotMaxTimestamp } ,
@@ -87,10 +82,6 @@ export default class BugsProvider extends MetadataApiProvider {
8782 headers : {
8883 'Content-Type' : 'application/json; charset=UTF-8' ,
8984 'Authorization' : `Bearer ${ accessToken } ` ,
90- 'User-Agent' : 'Mobile|Bugs|5.07.00|Android|16|SM-F936B|samsung|market|105070000' ,
91- 'X-BUGS-MS' : '58239824' ,
92- 'Invoke-page' : 'ALBUM_INFO' ,
93- 'Invoke-ids' : 'album|album_track|' ,
9485 } ,
9586 body,
9687 } ,
@@ -100,9 +91,8 @@ export default class BugsProvider extends MetadataApiProvider {
10091 private async requestAccessToken ( ) : Promise < ApiAccessToken > {
10192 const url = new URL ( 'https://secure.bugs.co.kr/api/5/appToken' ) ;
10293 url . searchParams . set ( 'client_id' , 'bugsapp_credentials_android' ) ;
103- url . searchParams . set ( 'client_secret' , 'd33b!z7xeu' ) ;
94+ url . searchParams . set ( 'client_secret' , bugsMobileClientSecret ) ;
10495 url . searchParams . set ( 'grant_type' , 'client_credentials' ) ;
105- url . searchParams . set ( 'device_id' , bugsDeviceId ) ;
10696 const { result } = await ( await fetch ( url , { method : 'POST' } ) ) . json ( ) ;
10797 return {
10898 accessToken : result . access_token ,
@@ -231,12 +221,11 @@ function parseYYYYMMDD(date: string): PartialDate {
231221
232222function mapReleaseType ( albumType ?: string ) : ReleaseGroupType [ ] | undefined {
233223 if ( ! albumType ) return undefined ;
234- if ( albumType . includes ( 'EP' ) || albumType . includes ( '미니' ) ) return [ 'EP ' ] ;
235- if ( albumType . includes ( '정규' ) ) return [ 'Album' ] ;
236- if ( albumType . includes ( '싱글' ) ) return [ 'Single ' ] ;
237- if ( albumType . includes ( '베스트' ) || albumType . includes ( '컴필' ) ) return [ 'Compilation' ] ;
224+ if ( albumType === '싱글' ) return [ 'Single ' ] ;
225+ if ( albumType === '정규' ) return [ 'Album' ] ;
226+ if ( albumType === 'EP(미니)' ) return [ 'EP ' ] ;
227+ if ( albumType === '베스트' || albumType === '컴필레이션' ) return [ 'Compilation' ] ;
238228 if ( albumType === 'OST' ) return [ 'Soundtrack' ] ;
239- if ( albumType . includes ( '라이브' ) ) return [ 'Live' ] ;
240- if ( albumType . includes ( '리믹스' ) ) return [ 'Remix' ] ;
229+ if ( albumType === '라이브' ) return [ 'Live' ] ;
241230 return undefined ;
242231}
0 commit comments