@@ -30,45 +30,41 @@ const getMediaURI = (type, id, callback) => {
3030
3131 let trackUrl = track [ `${ type } _url` ] || track . mp3_url ;
3232
33- const options = {
34- method : 'HEAD' ,
35- } ;
36-
37- fetch ( trackUrl , options ) . then ( ( res ) => {
38- if ( res . url ) {
39- trackUrl = res . url ;
40- }
41-
42- // wat.
43- // for some reason https doesn't work with cloudflare or phish.in and sonos.
44- // meh
45- if ( slug === 'phish' ) {
46- trackUrl = trackUrl
47- . replace ( 'https' , 'http' )
48- . replace ( 'phish.in/audio' , 'phishin-proxy.relisten.net/phishin-audio' ) ;
49- }
50-
51- // sonos requires a urlencode, but we can't encode the slashes
52- // encodeURI encodes a fully formed URL and won't encode the slashes
53- // also use relisten proxy
54- if ( slug === 'wsp' ) {
55- trackUrl = trackUrl . replace (
56- 'www.panicstream.com/streams' ,
57- 'phishin-proxy.relisten.net/panicstream'
58- ) ;
59- }
60-
61- callback ( {
62- getMediaURIResult : trackUrl , // 'http://192.168.0.101:3001/foo.mp3', //trackUrl,
63- httpHeaders : [
64- {
65- httpHeader : {
66- header : 'Referer' ,
67- value : 'https://www.panicstream.com' ,
68- } ,
69- } ,
70- ] ,
33+ let headers = [ ] ;
34+
35+ if ( / \/ a r c h i v e \. o r g / . test ( trackUrl ) ) {
36+ trackUrl = trackUrl . replace ( '://archive.org/' , '://audio.relisten.net/archive.org/' ) ;
37+ }
38+
39+ // wat.
40+ // for some reason https doesn't work with cloudflare or phish.in and sonos.
41+ // meh
42+ if ( slug === 'phish' ) {
43+ // trackUrl = trackUrl
44+ // .replace('https', 'http')
45+ // .replace('phish.in/audio', 'phishin-proxy.relisten.net/phishin-audio');
46+ }
47+
48+ // sonos requires a urlencode, but we can't encode the slashes
49+ // encodeURI encodes a fully formed URL and won't encode the slashes
50+ // also use relisten proxy
51+ if ( slug === 'wsp' ) {
52+ // trackUrl = trackUrl.replace(
53+ // 'www.panicstream.com/streams',
54+ // 'phishin-proxy.relisten.net/panicstream'
55+ // );
56+
57+ headers . push ( {
58+ httpHeader : {
59+ header : 'Referer' ,
60+ value : 'https://www.panicstream.com' ,
61+ } ,
7162 } ) ;
63+ }
64+
65+ callback ( {
66+ getMediaURIResult : trackUrl , // 'http://192.168.0.101:3001/foo.mp3', //trackUrl,
67+ httpHeaders : headers ,
7268 } ) ;
7369 } )
7470 . catch ( ( err ) => {
0 commit comments