From 1e5adef6188e542c53382c9d61bc68a08bb87f28 Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Fri, 19 Sep 2025 21:30:34 +0200 Subject: [PATCH] deploy --- 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 40d0d19..485437e 100644 --- a/Last.fm/index.js +++ b/Last.fm/index.js @@ -1 +1 @@ -(function(E,S,p,g,a,I,d,$,x){"use strict";const i={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:"https://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/letup",GITHUB_COMMITS_URL:"https://github.com/kmmiio99o/letup/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;ni.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,e;return await new Promise(function(n){return setTimeout(n,i.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(e){return!e||i.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();var H=function(t){return t[t.PLAYING=0]="PLAYING",t[t.STREAMING=1]="STREAMING",t[t.LISTENING=2]="LISTENING",t[t.COMPETING=5]="COMPETING",t}(H||{});const o=function(...t){return c.verboseLogging&&console.log("[Last.fm]",...t)},M=function(){function t(){P(this,t)}return k(t,[{key:"updateActivity",value:async function(){if(l.pluginStopped){o("Plugin is stopped, skipping update"),this.stopUpdates();return}o("Fetching last track...");try{if(!c.username||!c.apiKey)throw new Error("Username or API key not set");if(c.ignoreSpotify){if(K.findActivity(function(r){return r.sync_id})){o("Spotify is currently playing, clearing activity"),h("isSpotifyIgnored",!0),L();return}h("isSpotifyIgnored",!1)}const e=await F.fetchLatestScrobble();if(h("lastTrack",e),!e.nowPlaying){o("Last track is not currently playing"),L();return}if(l.lastTrackUrl===e.url){o("Track hasn't changed");return}const n={name:c.appName||i.DEFAULT_APP_NAME,flags:0,type:c.listeningTo?2:0,details:e.name,state:e.artist,status_display_type:1,application_id:i.APPLICATION_ID};if(n.name.includes("{{"))for(const r in e)n.name=n.name.replace(`{{${r}}}`,e[r]||"");if(c.showTimestamp&&(n.timestamps={start:Date.now()|0}),e.album){const r=await z([e.albumArt]);r[0]&&(n.assets={large_image:r[0],large_text:e.album})}o("Setting activity:",n),h("lastActivity",n),await D(n),l.lastTrackUrl=e.url,l.lastActivity=n,this.consecutiveFailures=0,o("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>=i.MAX_RETRY_ATTEMPTS&&(o(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var e=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),o("Starting reconnection process"),this.reconnectTimer=setInterval(function(){o("Attempting to reconnect..."),e.initialize().then(function(){o("Reconnection successful"),e.stopReconnection()}).catch(function(n){o("Reconnection failed:",n)})},i.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(l.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(c.timeInterval)||i.DEFAULT_SETTINGS.timeInterval)*1e3,i.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return e.updateActivity()},n),o(`Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){l.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),L()}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t}().getInstance(),G=function(){return M.initialize()},V=function(){return M.stop()},{FormText:O}=$.Forms,l={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},B=i.DEFAULT_SETTINGS;for(const t in B)S.plugin.storage[t]=S.plugin.storage[t]??B[t];const c=new Proxy(S.plugin.storage,{get(t,e){return t[e]},set(t,e,n){return t[e]=n,!0}}),j=x.lazy(function(){return Promise.resolve().then(function(){return ee}).catch(function(t){return console.error("[Last.fm] Failed to load settings:",t),{default:function(){return a.React.createElement(I.ScrollView,{style:{flex:1},contentContainerStyle:{padding:16}},a.React.createElement(O,{style:{color:"#ED4245"}},"Failed to load Last.fm settings. Please check your connection and reload Discord."))}}})});let _=0;const q=3,X=5e3;async function m(){try{await G(),_=0}catch(t){console.error("[Last.fm] Initialization error:",t),_++,_=i.MIN_UPDATE_INTERVAL?(T("timeInterval",w),n()):g.showToast(`Minimum interval is ${i.MIN_UPDATE_INTERVAL} seconds`,p.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),a.React.createElement(A,{title:"Options"},a.React.createElement(v,{label:"Show 'Listening to' instead of 'Playing'",value:u("listeningTo",i.DEFAULT_SETTINGS.listeningTo),onValueChange:function(s){T("listeningTo",s),n()}}),a.React.createElement(v,{label:"Show Timestamp",value:u("showTimestamp",i.DEFAULT_SETTINGS.showTimestamp),onValueChange:function(s){T("showTimestamp",s),n()}}),a.React.createElement(v,{label:"Ignore when Spotify is playing",value:u("ignoreSpotify",i.DEFAULT_SETTINGS.ignoreSpotify),onValueChange:function(s){T("ignoreSpotify",s),n()}}),a.React.createElement(v,{label:"Verbose Logging",value:u("verboseLogging",i.DEFAULT_SETTINGS.verboseLogging),onValueChange:function(s){T("verboseLogging",s),n()}})),a.React.createElement(A,{title:"Plugin Status"},a.React.createElement(f,{label:"Status",subLabel:l.pluginStopped?"Stopped":"Running"}),a.React.createElement(f,{label:"Last Update",subLabel:l.lastTrackUrl?"Success":"No track data"})),a.React.createElement(A,{title:"About"},a.React.createElement(f,{label:"Version",subLabel:Q}),a.React.createElement(f,{label:"View Changelog",trailing:a.React.createElement(f.Arrow,null),onPress:function(){I.Linking.openURL(i.GITHUB_COMMITS_URL)}}))))}var ee=Object.freeze({__proto__:null,default:Z});return E.currentSettings=c,E.default=J,E.pluginState=l,Object.defineProperty(E,"__esModule",{value:!0}),E})({},vendetta,vendetta.ui.assets,vendetta.ui.toasts,vendetta.metro.common,vendetta.metro.common.ReactNative,vendetta.metro,vendetta.ui.components,window.React); +(function(m,A,g,p,n,I,d,x,O){"use strict";const i={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:"https://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/letup",GITHUB_COMMITS_URL:"https://github.com/kmmiio99o/letup/commits/main/"};function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var a=0;ai.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,e;return await new Promise(function(a){return setTimeout(a,i.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(e){return!e||i.LFM_DEFAULT_COVER_HASHES.some(function(a){return e.includes(a)})?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();var z=function(t){return t[t.PLAYING=0]="PLAYING",t[t.STREAMING=1]="STREAMING",t[t.LISTENING=2]="LISTENING",t[t.COMPETING=5]="COMPETING",t}(z||{});const o=function(...t){return c.verboseLogging&&console.log("[Last.fm]",...t)},M=function(){function t(){P(this,t)}return U(t,[{key:"updateActivity",value:async function(){if(l.pluginStopped){o("Plugin is stopped, skipping update"),this.stopUpdates();return}o("Fetching last track...");try{if(!c.username||!c.apiKey)throw new Error("Username or API key not set");if(c.ignoreSpotify){if(K.findActivity(function(s){return s.sync_id})){o("Spotify is currently playing, clearing activity"),h("isSpotifyIgnored",!0),w();return}h("isSpotifyIgnored",!1)}const e=await F.fetchLatestScrobble();if(h("lastTrack",e),!e.nowPlaying){o("Last track is not currently playing"),w();return}if(l.lastTrackUrl===e.url){o("Track hasn't changed");return}const a={name:c.appName||i.DEFAULT_APP_NAME,flags:0,type:c.listeningTo?2:0,details:e.name,state:e.artist,status_display_type:1,application_id:i.APPLICATION_ID};if(a.name.includes("{{"))for(const s in e)a.name=a.name.replace(`{{${s}}}`,e[s]||"");if(c.showTimestamp&&(a.timestamps={start:Date.now()|0}),e.album){const s=await j([e.albumArt]);s[0]&&(a.assets={large_image:s[0],large_text:e.album})}o("Setting activity:",a),h("lastActivity",a),await D(a),l.lastTrackUrl=e.url,l.lastActivity=a,this.consecutiveFailures=0,o("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>=i.MAX_RETRY_ATTEMPTS&&(o(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var e=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),o("Starting reconnection process"),this.reconnectTimer=setInterval(function(){o("Attempting to reconnect..."),e.initialize().then(function(){o("Reconnection successful"),e.stopReconnection()}).catch(function(a){o("Reconnection failed:",a)})},i.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(l.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const a=Math.max((Number(c.timeInterval)||i.DEFAULT_SETTINGS.timeInterval)*1e3,i.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return e.updateActivity()},a),o(`Update timer started with interval: ${a}ms`)}},{key:"stop",value:function(){l.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),w()}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t}().getInstance(),G=function(){return M.initialize()},V=function(){return M.stop()},{FormText:$}=x.Forms,l={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},B=i.DEFAULT_SETTINGS;for(const t in B)A.plugin.storage[t]=A.plugin.storage[t]??B[t];const c=new Proxy(A.plugin.storage,{get(t,e){return t[e]},set(t,e,a){return t[e]=a,!0}}),H=O.lazy(function(){return Promise.resolve().then(function(){return ae}).catch(function(t){return console.error("[Last.fm] Failed to load settings:",t),{default:function(){return n.React.createElement(I.ScrollView,{style:{flex:1},contentContainerStyle:{padding:16}},n.React.createElement($,{style:{color:"#ED4245"}},"Failed to load Last.fm settings. Please check your connection and reload Discord."))}}})});let _=0;const q=3,X=5e3;async function R(){try{await G(),_=0}catch(t){console.error("[Last.fm] Initialization error:",t),_++,_=i.MIN_UPDATE_INTERVAL?(T("timeInterval",S),a()):p.showToast(`Minimum interval is ${i.MIN_UPDATE_INTERVAL} seconds`,g.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),n.React.createElement(y,{title:"Options"},n.React.createElement(b,{label:"Show 'Listening to' instead of 'Playing'",value:f("listeningTo",i.DEFAULT_SETTINGS.listeningTo),onValueChange:function(r){T("listeningTo",r),a()}}),n.React.createElement(b,{label:"Show Timestamp",value:f("showTimestamp",i.DEFAULT_SETTINGS.showTimestamp),onValueChange:function(r){T("showTimestamp",r),a()}}),n.React.createElement(b,{label:"Ignore when Spotify is playing",value:f("ignoreSpotify",i.DEFAULT_SETTINGS.ignoreSpotify),onValueChange:function(r){T("ignoreSpotify",r),a()}}),n.React.createElement(b,{label:"Verbose Logging",value:f("verboseLogging",i.DEFAULT_SETTINGS.verboseLogging),onValueChange:function(r){T("verboseLogging",r),a()}})),n.React.createElement(y,{title:"Plugin Status"},n.React.createElement(u,{label:"Status",subLabel:l.pluginStopped?"Stopped":"Running"}),n.React.createElement(u,{label:"Last Update",subLabel:l.lastTrackUrl?"Success":"No track data"})),n.React.createElement(y,{title:"About"},n.React.createElement(u,{label:"Version",subLabel:W}),n.React.createElement(u,{label:"View Changelog",trailing:n.React.createElement(u.Arrow,null),onPress:function(){I.Linking.openURL(i.GITHUB_COMMITS_URL)}})),n.React.createElement(y,{title:"Changelog"},Q.map(function(r,S){return n.React.createElement(u,{key:S,label:`v${r.version} (${r.date})`,subLabel:r.changes.join(", ")})}))))}var ne={settings:function(){return n.React.createElement(n.React.Suspense,{fallback:n.React.createElement(I.View,{style:{flex:1,justifyContent:"center",alignItems:"center"}},n.React.createElement(ee,null,"Loading Last.fm settings..."))},n.React.createElement(te,null))},onLoad(){if(l.pluginStopped=!1,!c.username||!c.apiKey){p.showToast("Please configure Last.fm username and API key in settings",g.getAssetIDByName("ic_warning"));return}}},ae=Object.freeze({__proto__:null,default:ne});return m.currentSettings=c,m.default=J,m.pluginState=l,Object.defineProperty(m,"__esModule",{value:!0}),m})({},vendetta,vendetta.ui.assets,vendetta.ui.toasts,vendetta.metro.common,vendetta.metro.common.ReactNative,vendetta.metro,vendetta.ui.components,window.React); diff --git a/Last.fm/manifest.json b/Last.fm/manifest.json index 1150740..6f99f42 100644 --- a/Last.fm/manifest.json +++ b/Last.fm/manifest.json @@ -1 +1 @@ -{"authors":[{"name":"pylix","id":"492949202121261067"},{"name":"kmmiio99o","id":"879393496627306587"}],"main":"index.js","name":"Last.fm","description":"Show off your last.fm status on your Discord profile.","vendetta":{"icon":"ic_stage_music"},"hash":"832618ddae367e1278bbda7aa69029424fdc16d169b8590dfcf3a842ae57591e"} \ No newline at end of file +{"authors":[{"name":"pylix","id":"492949202121261067"},{"name":"kmmiio99o","id":"879393496627306587"}],"main":"index.js","name":"Last.fm","description":"Show off your last.fm status on your Discord profile.","vendetta":{"icon":"ic_stage_music"},"hash":"f09bc4f0f152dfcb6bc7e0aa347b03435953a224199b6ed9fcee5bb3b8f2b997"} \ No newline at end of file