From 7f86a8ffa321510db3b45b6bca2dde3f6522d222 Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Fri, 2 Jan 2026 18:27:05 +0000 Subject: [PATCH] deploy: dbcc2a433853f64a228c9e0693e6fa9766653d1f --- Last.fm/index.js | 2 +- Last.fm/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Last.fm/index.js b/Last.fm/index.js index 6b48e01..e5ad7fc 100644 --- a/Last.fm/index.js +++ b/Last.fm/index.js @@ -1 +1 @@ -(function(I,A,a,g,T,O,h,k){"use strict";const s={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",MIN_UPDATE_INTERVAL:3,MAX_RETRY_ATTEMPTS:3,RETRY_DELAY:5e3,LFM_API_BASE_URL:"http://ws.audioscrobbler.com/2.0",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"],DEFAULT_SETTINGS:{username:"",apiKey:"",appName:"Music",timeInterval:5,showTimestamp:!0,listeningTo:!0,ignoreSpotify:!0,verboseLogging:!1},GITHUB_URL:"https://github.com/kmmiio99o/vd-plugins",GITHUB_COMMITS_URL:"https://github.com/kmmiio99o/vd-plugins/commits/main/"};function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function U(t,e){for(var n=0;n0&&(p=r+Math.floor(i/1e3))}catch(m){console.warn("Failed to fetch track duration",m)}return{name:e.name,artist:e.artist.name,album:e.album["#text"],albumArt:await this.handleAlbumCover(e.image?.find(function(m){return m.size==="large"})?.["#text"]),url:e.url,date:e.date?.["#text"]??"now",nowPlaying:n,loved:e.loved==="1",from:r,to:p}}catch(e){if(this.retryCount++,this.retryCount>s.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,e;return await new Promise(function(n){return setTimeout(n,s.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(e){return!e||s.LFM_DEFAULT_COVER_HASHES.some(function(n){return e.includes(n)})?null:e}},{key:"getLastError",value:function(){return this.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t})().getInstance();function H(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}var j=(function(t){return t[t.PLAYING=0]="PLAYING",t[t.STREAMING=1]="STREAMING",t[t.LISTENING=2]="LISTENING",t[t.COMPETING=5]="COMPETING",t})(j||{});const l=function(...t){return o.verboseLogging&&console.log("[Last.fm]",...t)},$=(function(){function t(){P(this,t)}return C(t,[{key:"updateActivity",value:async function(){if(c.pluginStopped){l("Plugin is stopped, skipping update"),this.stopUpdates();return}l("Fetching last track...");try{if(!o.username||!o.apiKey)throw new Error("Username or API key not set");if(o.ignoreSpotify){if(Y.findActivity(function(r){return r.sync_id})){l("Spotify is currently playing, clearing activity"),y("isSpotifyIgnored",!0),L();return}y("isSpotifyIgnored",!1)}const e=await M.fetchLatestScrobble();if(y("lastTrack",e),!e.nowPlaying){l("Last track is not currently playing"),L();return}if(c.lastTrackUrl===e.url){l("Track hasn't changed");return}const n={name:o.appName||s.DEFAULT_APP_NAME,flags:0,type:o.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,status_display_type:1,application_id:s.APPLICATION_ID};if(n.name.includes("{{"))for(const r in e)n.name=n.name.replace(`{{${r}}}`,e[r]||"");if(o.showTimestamp&&typeof e.from=="number"&&(n.timestamps={start:e.from*1e3,...typeof e.to=="number"&&{end:e.to*1e3}}),e.album){const r=await K([e.albumArt]);r[0]&&(n.assets={large_image:r[0],large_text:`on ${e.album}${o.showTimestamp&&e.to?` \u2022 ${H((e.to-e.from)/1e3)}`:""}`})}l("Setting activity:",n),y("lastActivity",n),await F(n),c.lastTrackUrl=e.url,c.lastActivity=n,this.consecutiveFailures=0,l("Activity set successfully!")}catch(e){console.error("[Last.fm] Update error:",e),this.handleError(e)}}},{key:"handleError",value:function(e){this.consecutiveFailures++,y("lastError",e),this.consecutiveFailures>=s.MAX_RETRY_ATTEMPTS&&(l(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var e=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),l("Starting reconnection process"),this.reconnectTimer=setInterval(function(){l("Attempting to reconnect..."),e.initialize().then(function(){l("Reconnection successful"),e.stopReconnection()}).catch(function(n){l("Reconnection failed:",n)})},s.RETRY_DELAY))}},{key:"stopReconnection",value:function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=void 0),this.isReconnecting=!1,this.consecutiveFailures=0}},{key:"stopUpdates",value:function(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=void 0)}},{key:"initialize",value:async function(){var e=this;if(c.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(o.timeInterval)||s.DEFAULT_SETTINGS.timeInterval)*1e3,s.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return e.updateActivity()},n),l(`Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){c.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),L()}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t})().getInstance(),V=function(){return $.initialize()},G=function(){return $.stop()},z=[{version:"2.3.0",date:"2025-09-19",changes:["1. I TRIED SO HARD 2. remove backend error 3. factor settings tab 4. factor V2 5. factor V3 6. factor V4 7. factor V5 8. factor V6 9. Full settings refactor :3"]},{version:"2.2.0",date:"2025-09-13",changes:["Remember kids! Do not sniff crack!"]},{version:"2.0.0",date:"2025-09-13",changes:["Fix settings scrolling"]},{version:"1.3.0",date:"2025-09-13",changes:["fix reanimated"]},{version:"1.2.0",date:"2025-09-13",changes:["test"]},{version:"1.1.0",date:"2025-09-12",changes:["fixed reanimated issue??"]}],q="2.3.0",{ScrollView:X}=h.findByProps("ScrollView"),{TableRowGroup:E,TableSwitchRow:R,Stack:_,TableRow:u}=h.findByProps("TableSwitchRow","TableRowGroup","Stack","TableRow"),{TextInput:w}=h.findByProps("TextInput"),{FormText:ie}=h.findByProps("FormText"),f=function(t,e=""){return A.plugin.storage[t]??e},d=function(t,e){return A.plugin.storage[t]=e};function J(){const[t,e]=a.React.useReducer(function(i){return~i},0),n=function(){return e()},[r,p]=a.React.useState(!1),m=async function(){const i=f("username"),S=f("apiKey");if(!i||!S){T.showToast("Please enter both username and API key",g.getAssetIDByName("Small"));return}p(!0);try{await M.fetchLatestScrobble(),T.showToast("Connection successful!",g.getAssetIDByName("Check")),await V()}catch(ee){T.showToast(`Connection failed: ${ee.message}`,g.getAssetIDByName("Small"))}finally{p(!1)}};return a.React.createElement(X,{style:{flex:1},contentContainerStyle:{padding:10}},a.React.createElement(_,{spacing:8},a.React.createElement(E,{title:"Account Settings"},a.React.createElement(_,{spacing:4},a.React.createElement(w,{placeholder:"Last.fm Username",value:f("username"),onChange:function(i){d("username",i),n()},isClearable:!0}),a.React.createElement(w,{placeholder:"API Key",value:f("apiKey"),onChange:function(i){d("apiKey",i),n()},secureTextEntry:!0,isClearable:!0}),a.React.createElement(u,{label:"Get API Key",subLabel:"https://www.last.fm/api/",onPress:function(){return k.Linking.openURL("https://www.last.fm/api/")}})),a.React.createElement(u,{label:"Test Connection",trailing:r?a.React.createElement(u.Arrow,{loading:!0}):a.React.createElement(u.Arrow,null),onPress:m,disabled:r})),a.React.createElement(E,{title:"Display Settings"},a.React.createElement(_,{spacing:4},a.React.createElement(w,{placeholder:`App Name (Default: ${s.DEFAULT_SETTINGS.appName})`,value:f("appName",s.DEFAULT_SETTINGS.appName),onChange:function(i){d("appName",i),n()},isClearable:!0}),a.React.createElement(w,{placeholder:`Update Interval (Default: ${s.DEFAULT_SETTINGS.timeInterval}s)`,value:String(f("timeInterval",s.DEFAULT_SETTINGS.timeInterval)),onChange:function(i){const S=Number(i);S>=s.MIN_UPDATE_INTERVAL?(d("timeInterval",S),n()):T.showToast(`Minimum interval is ${s.MIN_UPDATE_INTERVAL} seconds`,g.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),a.React.createElement(E,{title:"Options"},a.React.createElement(R,{label:"Show 'Listening to' instead of 'Playing'",value:f("listeningTo",s.DEFAULT_SETTINGS.listeningTo),onValueChange:function(i){d("listeningTo",i),n()}}),a.React.createElement(R,{label:"Show Timestamp",value:f("showTimestamp",s.DEFAULT_SETTINGS.showTimestamp),onValueChange:function(i){d("showTimestamp",i),n()}}),a.React.createElement(R,{label:"Ignore when Spotify is playing",value:f("ignoreSpotify",s.DEFAULT_SETTINGS.ignoreSpotify),onValueChange:function(i){d("ignoreSpotify",i),n()}}),a.React.createElement(R,{label:"Verbose Logging",value:f("verboseLogging",s.DEFAULT_SETTINGS.verboseLogging),onValueChange:function(i){d("verboseLogging",i),n()}})),a.React.createElement(E,{title:"Plugin Status"},a.React.createElement(u,{label:"Status",subLabel:c.pluginStopped?"Stopped":"Running"}),a.React.createElement(u,{label:"Last Update",subLabel:c.lastTrackUrl?"Success":"No track data"})),a.React.createElement(E,{title:"About"},a.React.createElement(u,{label:"Version",subLabel:q}),a.React.createElement(u,{label:"View Changelog",trailing:a.React.createElement(u.Arrow,null),onPress:function(){k.Linking.openURL(s.GITHUB_COMMITS_URL)}})),a.React.createElement(E,{title:"Changelog"},z.map(function(i,S){return a.React.createElement(u,{key:S,label:`v${i.version} (${i.date})`,subLabel:i.changes.join(", ")})}))))}const{FormText:re}=O.Forms,c={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},B=s.DEFAULT_SETTINGS;for(const t in B)A.plugin.storage[t]=A.plugin.storage[t]??B[t];const o=new Proxy(A.plugin.storage,{get(t,e){return t[e]},set(t,e,n){return t[e]=n,!0}});let N=0;const Q=3,W=5e3;async function v(){try{await V(),N=0}catch(t){console.error("[Last.fm] Initialization error:",t),N++,N0&&(f=i+Math.floor(r/1e3))}catch(m){console.warn("[Last.fm] Failed to fetch track duration",m)}return{name:e.name,artist:e.artist.name,album:e.album["#text"],albumArt:await this.handleAlbumCover(e.image?.find(function(m){return m.size==="large"})?.["#text"]),url:e.url,date:e.date?.["#text"]??"now",nowPlaying:n,loved:e.loved==="1",from:i,to:f}}catch(e){if(this.retryCount++,this.retryCount>s.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,console.error("[Last.fm] Max retry attempts reached"),e;return await new Promise(function(n){return setTimeout(n,s.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(e){return!e||s.LFM_DEFAULT_COVER_HASHES.some(function(n){return e.includes(n)})?null:e}},{key:"getLastError",value:function(){return this.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t})().getInstance();function H(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}var j=(function(t){return t[t.PLAYING=0]="PLAYING",t[t.STREAMING=1]="STREAMING",t[t.LISTENING=2]="LISTENING",t[t.COMPETING=5]="COMPETING",t})(j||{});const d=function(...t){return o.verboseLogging&&console.log("[Last.fm]",...t)},$=(function(){function t(){P(this,t)}return C(t,[{key:"updateActivity",value:async function(){if(c.pluginStopped){d("Plugin is stopped, skipping update"),this.stopUpdates();return}d("Fetching last track...");try{if(!o.username||!o.apiKey)throw new Error("Username or API key not set");if(o.ignoreSpotify){if(Y.findActivity(function(i){return i.sync_id})){d("Spotify is currently playing, clearing activity"),h("isSpotifyIgnored",!0),_();return}h("isSpotifyIgnored",!1)}const e=await M.fetchLatestScrobble();if(h("lastTrack",e),!e.nowPlaying){d("Last track is not currently playing"),_();return}if(c.lastTrackUrl===e.url){d("Track hasn't changed");return}const n={name:o.appName||s.DEFAULT_APP_NAME,flags:0,type:o.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,status_display_type:1,application_id:s.APPLICATION_ID};if(n.name.includes("{{"))for(const i in e)n.name=n.name.replace(`{{${i}}}`,e[i]||"");if(o.showTimestamp&&typeof e.from=="number"&&(n.timestamps={start:e.from*1e3,...typeof e.to=="number"&&{end:e.to*1e3}}),e.album){const i=await K([e.albumArt]);i[0]&&(n.assets={large_image:i[0],large_text:`on ${e.album}${o.showTimestamp&&e.to?` \u2022 ${H((e.to-e.from)/1e3)}`:""}`})}d("Setting activity:",n),h("lastActivity",n),await F(n),c.lastTrackUrl=e.url,c.lastActivity=n,this.consecutiveFailures=0,d("Activity set successfully!")}catch(e){console.error("[Last.fm] Update error:",e),this.handleError(e)}}},{key:"handleError",value:function(e){this.consecutiveFailures++,h("lastError",e),this.consecutiveFailures>=s.MAX_RETRY_ATTEMPTS&&(console.log(`[Last.fm] Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var e=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),console.log("[Last.fm] Starting reconnection process"),this.reconnectTimer=setInterval(function(){console.log("[Last.fm] Attempting to reconnect..."),e.initialize().then(function(){console.log("[Last.fm] Reconnection successful"),e.stopReconnection()}).catch(function(n){console.log("[Last.fm] Reconnection failed:",n)})},s.RETRY_DELAY))}},{key:"stopReconnection",value:function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=void 0),this.isReconnecting=!1,this.consecutiveFailures=0}},{key:"stopUpdates",value:function(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=void 0)}},{key:"initialize",value:async function(){var e=this;if(c.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(o.timeInterval)||s.DEFAULT_SETTINGS.timeInterval)*1e3,s.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return e.updateActivity()},n),console.log(`[Last.fm] Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){c.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),_(),console.log("[Last.fm] Plugin stopped")}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t})().getInstance(),V=function(){return $.initialize()},G=function(){return $.stop()},z=[{version:"2.3.0",date:"2025-09-19",changes:["1. I TRIED SO HARD 2. remove backend error 3. factor settings tab 4. factor V2 5. factor V3 6. factor V4 7. factor V5 8. factor V6 9. Full settings refactor :3"]},{version:"2.2.0",date:"2025-09-13",changes:["Remember kids! Do not sniff crack!"]},{version:"2.0.0",date:"2025-09-13",changes:["Fix settings scrolling"]},{version:"1.3.0",date:"2025-09-13",changes:["fix reanimated"]},{version:"1.2.0",date:"2025-09-13",changes:["test"]},{version:"1.1.0",date:"2025-09-12",changes:["fixed reanimated issue??"]}],q="2.3.0",{ScrollView:X}=g.findByProps("ScrollView"),{TableRowGroup:T,TableSwitchRow:b,Stack:k,TableRow:l}=g.findByProps("TableSwitchRow","TableRowGroup","Stack","TableRow"),{TextInput:R}=g.findByProps("TextInput"),{FormText:re}=g.findByProps("FormText"),u=function(t,e=""){return S.plugin.storage[t]??e},p=function(t,e){return S.plugin.storage[t]=e};function J(){const[t,e]=a.React.useReducer(function(r){return~r},0),n=function(){return e()},[i,f]=a.React.useState(!1),m=async function(){const r=u("username"),y=u("apiKey");if(!r||!y){v.showToast("Please enter both username and API key",A.getAssetIDByName("Small"));return}f(!0);try{await M.fetchLatestScrobble(),v.showToast("Connection successful!",A.getAssetIDByName("Check")),await V()}catch(ee){v.showToast(`Connection failed: ${ee.message}`,A.getAssetIDByName("Small"))}finally{f(!1)}};return a.React.createElement(X,{style:{flex:1},contentContainerStyle:{padding:10}},a.React.createElement(k,{spacing:8},a.React.createElement(T,{title:"Account Settings"},a.React.createElement(k,{spacing:4},a.React.createElement(R,{placeholder:"Last.fm Username",value:u("username"),onChange:function(r){p("username",r),n()},isClearable:!0}),a.React.createElement(R,{placeholder:"API Key",value:u("apiKey"),onChange:function(r){p("apiKey",r),n()},secureTextEntry:!0,isClearable:!0}),a.React.createElement(l,{label:"Get API Key",subLabel:"https://www.last.fm/api/",onPress:function(){return N.Linking.openURL("https://www.last.fm/api/")}})),a.React.createElement(l,{label:"Test Connection",trailing:i?a.React.createElement(l.Arrow,{loading:!0}):a.React.createElement(l.Arrow,null),onPress:m,disabled:i})),a.React.createElement(T,{title:"Display Settings"},a.React.createElement(k,{spacing:4},a.React.createElement(R,{placeholder:`App Name (Default: ${s.DEFAULT_SETTINGS.appName})`,value:u("appName",s.DEFAULT_SETTINGS.appName),onChange:function(r){p("appName",r),n()},isClearable:!0}),a.React.createElement(R,{placeholder:`Update Interval (Default: ${s.DEFAULT_SETTINGS.timeInterval}s)`,value:String(u("timeInterval",s.DEFAULT_SETTINGS.timeInterval)),onChange:function(r){const y=Number(r);y>=s.MIN_UPDATE_INTERVAL?(p("timeInterval",y),n()):v.showToast(`Minimum interval is ${s.MIN_UPDATE_INTERVAL} seconds`,A.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),a.React.createElement(T,{title:"Options"},a.React.createElement(b,{label:"Show 'Listening to' instead of 'Playing'",value:u("listeningTo",s.DEFAULT_SETTINGS.listeningTo),onValueChange:function(r){p("listeningTo",r),n()}}),a.React.createElement(b,{label:"Show Timestamp",value:u("showTimestamp",s.DEFAULT_SETTINGS.showTimestamp),onValueChange:function(r){p("showTimestamp",r),n()}}),a.React.createElement(b,{label:"Ignore when Spotify is playing",value:u("ignoreSpotify",s.DEFAULT_SETTINGS.ignoreSpotify),onValueChange:function(r){p("ignoreSpotify",r),n()}}),a.React.createElement(b,{label:"Verbose Logging",value:u("verboseLogging",s.DEFAULT_SETTINGS.verboseLogging),onValueChange:function(r){p("verboseLogging",r),n()}})),a.React.createElement(T,{title:"Plugin Status"},a.React.createElement(l,{label:"Status",subLabel:c.pluginStopped?"Stopped":"Running"}),a.React.createElement(l,{label:"Last Update",subLabel:c.lastTrackUrl?"Success":"No track data"})),a.React.createElement(T,{title:"About"},a.React.createElement(l,{label:"Version",subLabel:q}),a.React.createElement(l,{label:"View Changelog",trailing:a.React.createElement(l.Arrow,null),onPress:function(){N.Linking.openURL(s.GITHUB_COMMITS_URL)}})),a.React.createElement(T,{title:"Changelog"},z.map(function(r,y){return a.React.createElement(l,{key:y,label:`v${r.version} (${r.date})`,subLabel:r.changes.join(", ")})}))))}const{FormText:ie}=x.Forms,c={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},O=s.DEFAULT_SETTINGS;for(const t in O)S.plugin.storage[t]=S.plugin.storage[t]??O[t];const o=new Proxy(S.plugin.storage,{get(t,e){return t[e]},set(t,e,n){return t[e]=n,!0}});let w=0;const Q=3,W=5e3;async function I(){try{await V(),w=0,console.log("[Last.fm] Successfully connected to Last.fm")}catch(t){console.error("[Last.fm] Initialization error:",t),w++,w