From 7e3bdc3e123c4ed43e6e580e9478a84af63b7455 Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Fri, 19 Sep 2025 21:06:42 +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 358a7f3..f857e8e 100644 --- a/Last.fm/index.js +++ b/Last.fm/index.js @@ -1 +1 @@ -(function(d,S,O,f,p,a,h,g,V,x){"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:"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 b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){for(var n=0;ns.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,t;return await new Promise(function(n){return setTimeout(n,s.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(t){return!t||s.LFM_DEFAULT_COVER_HASHES.some(function(n){return t.includes(n)})?null:t}},{key:"getLastError",value:function(){return this.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}().getInstance();var K=function(e){return e[e.PLAYING=0]="PLAYING",e[e.STREAMING=1]="STREAMING",e[e.LISTENING=2]="LISTENING",e[e.COMPETING=5]="COMPETING",e}(K||{});const l=function(...e){return i.verboseLogging&&console.log("[Last.fm]",...e)},C=function(){function e(){b(this,e)}return N(e,[{key:"updateActivity",value:async function(){if(o.pluginStopped){l("Plugin is stopped, skipping update"),this.stopUpdates();return}l("Fetching last track...");try{if(!i.username||!i.apiKey)throw new Error("Username or API key not set");if(i.ignoreSpotify){if($.findActivity(function(c){return c.sync_id})){l("Spotify is currently playing, clearing activity"),T("isSpotifyIgnored",!0),v();return}T("isSpotifyIgnored",!1)}const t=await U.fetchLatestScrobble();if(T("lastTrack",t),!t.nowPlaying){l("Last track is not currently playing"),v();return}if(o.lastTrackUrl===t.url){l("Track hasn't changed");return}const n={name:i.appName||s.DEFAULT_APP_NAME,flags:0,type:i.listeningTo?2:0,details:t.name,state:t.artist,status_display_type:1,application_id:s.APPLICATION_ID};if(n.name.includes("{{"))for(const c in t)n.name=n.name.replace(`{{${c}}}`,t[c]||"");if(i.showTimestamp&&(n.timestamps={start:Date.now()|0}),t.album){const c=await Y([t.albumArt]);c[0]&&(n.assets={large_image:c[0],large_text:t.album})}l("Setting activity:",n),T("lastActivity",n),await k(n),o.lastTrackUrl=t.url,o.lastActivity=n,this.consecutiveFailures=0,l("Activity set successfully!")}catch(t){console.error("[Last.fm] Update error:",t),this.handleError(t)}}},{key:"handleError",value:function(t){this.consecutiveFailures++,T("lastError",t),this.consecutiveFailures>=s.MAX_RETRY_ATTEMPTS&&(l(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var t=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),l("Starting reconnection process"),this.reconnectTimer=setInterval(function(){l("Attempting to reconnect..."),t.initialize().then(function(){l("Reconnection successful"),t.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 t=this;if(o.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(i.timeInterval)||s.DEFAULT_SETTINGS.timeInterval)*1e3,s.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return t.updateActivity()},n),l(`Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){o.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),v()}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}().getInstance(),D=function(){return C.initialize()},F=function(){return C.stop()},{FormText:M}=V.Forms,o={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},G=s.DEFAULT_SETTINGS;for(const e in G)S.plugin.storage[e]=S.plugin.storage[e]??G[e];const i=new Proxy(S.plugin.storage,{get(e,t){return e[t]},set(e,t,n){return e[t]=n,!0}}),z=x.lazy(function(){return Promise.resolve().then(function(){return Q}).catch(function(e){return console.error("[Last.fm] Failed to load settings:",e),{default:function(){return a.React.createElement(h.ScrollView,{style:{flex:1},contentContainerStyle:{padding:16}},a.React.createElement(M,{style:{color:"#ED4245"}},"Failed to load Last.fm settings. Please check your connection and reload Discord."))}}})});let w=0;const H=3,j=5e3;async function y(){try{await D(),w=0}catch(e){console.error("[Last.fm] Initialization error:",e),w++,w=s.MIN_UPDATE_INTERVAL?n("timeInterval",m):p.showToast(`Minimum interval is ${s.MIN_UPDATE_INTERVAL} seconds`,f.getAssetIDByName("Small"))},keyboardType:"numeric"}))),a.React.createElement(E,{title:"Options"},a.React.createElement(I,{label:"Show 'Listening to' instead of 'Playing'",value:i.listeningTo??s.DEFAULT_SETTINGS.listeningTo,onValueChange:function(r){return n("listeningTo",r)}}),a.React.createElement(I,{label:"Show Timestamp",value:i.showTimestamp??s.DEFAULT_SETTINGS.showTimestamp,onValueChange:function(r){return n("showTimestamp",r)}}),a.React.createElement(I,{label:"Ignore when Spotify is playing",value:i.ignoreSpotify??s.DEFAULT_SETTINGS.ignoreSpotify,onValueChange:function(r){return n("ignoreSpotify",r)}}),a.React.createElement(I,{label:"Verbose Logging",value:i.verboseLogging??s.DEFAULT_SETTINGS.verboseLogging,onValueChange:function(r){return n("verboseLogging",r)}})),a.React.createElement(E,{title:"Plugin Status"},a.React.createElement(u,{label:"Status",subLabel:o.pluginStopped?"Stopped":"Running"}),a.React.createElement(u,{label:"Last Update",subLabel:o.lastTrackUrl?"Success":"No track data"})),a.React.createElement(E,{title:"About"},a.React.createElement(u,{label:"Version",subLabel:X}),a.React.createElement(u,{label:"View Changelog",trailing:a.React.createElement(u.Arrow,null),onPress:function(){h.Linking.openURL(s.GITHUB_COMMITS_URL)}}))))}var Q=Object.freeze({__proto__:null,default:J});return d.currentSettings=i,d.default=q,d.pluginState=o,Object.defineProperty(d,"__esModule",{value:!0}),d})({},vendetta,vendetta.storage,vendetta.ui.assets,vendetta.ui.toasts,vendetta.metro.common,vendetta.metro.common.ReactNative,vendetta.metro,vendetta.ui.components,window.React); +(function(T,S,O,f,p,a,h,g,V,$){"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:"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 L(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){for(var n=0;ns.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,t;return await new Promise(function(n){return setTimeout(n,s.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(t){return!t||s.LFM_DEFAULT_COVER_HASHES.some(function(n){return t.includes(n)})?null:t}},{key:"getLastError",value:function(){return this.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}().getInstance();var K=function(e){return e[e.PLAYING=0]="PLAYING",e[e.STREAMING=1]="STREAMING",e[e.LISTENING=2]="LISTENING",e[e.COMPETING=5]="COMPETING",e}(K||{});const o=function(...e){return i.verboseLogging&&console.log("[Last.fm]",...e)},C=function(){function e(){L(this,e)}return N(e,[{key:"updateActivity",value:async function(){if(c.pluginStopped){o("Plugin is stopped, skipping update"),this.stopUpdates();return}o("Fetching last track...");try{if(!i.username||!i.apiKey)throw new Error("Username or API key not set");if(i.ignoreSpotify){if(x.findActivity(function(l){return l.sync_id})){o("Spotify is currently playing, clearing activity"),d("isSpotifyIgnored",!0),v();return}d("isSpotifyIgnored",!1)}const t=await U.fetchLatestScrobble();if(d("lastTrack",t),!t.nowPlaying){o("Last track is not currently playing"),v();return}if(c.lastTrackUrl===t.url){o("Track hasn't changed");return}const n={name:i.appName||s.DEFAULT_APP_NAME,flags:0,type:i.listeningTo?2:0,details:t.name,state:t.artist,status_display_type:1,application_id:s.APPLICATION_ID};if(n.name.includes("{{"))for(const l in t)n.name=n.name.replace(`{{${l}}}`,t[l]||"");if(i.showTimestamp&&(n.timestamps={start:Date.now()|0}),t.album){const l=await Y([t.albumArt]);l[0]&&(n.assets={large_image:l[0],large_text:t.album})}o("Setting activity:",n),d("lastActivity",n),await k(n),c.lastTrackUrl=t.url,c.lastActivity=n,this.consecutiveFailures=0,o("Activity set successfully!")}catch(t){console.error("[Last.fm] Update error:",t),this.handleError(t)}}},{key:"handleError",value:function(t){this.consecutiveFailures++,d("lastError",t),this.consecutiveFailures>=s.MAX_RETRY_ATTEMPTS&&(o(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var t=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),o("Starting reconnection process"),this.reconnectTimer=setInterval(function(){o("Attempting to reconnect..."),t.initialize().then(function(){o("Reconnection successful"),t.stopReconnection()}).catch(function(n){o("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 t=this;if(c.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(i.timeInterval)||s.DEFAULT_SETTINGS.timeInterval)*1e3,s.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return t.updateActivity()},n),o(`Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){c.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),v()}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}().getInstance(),D=function(){return C.initialize()},F=function(){return C.stop()},{FormText:M}=V.Forms,c={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},G=s.DEFAULT_SETTINGS;for(const e in G)S.plugin.storage[e]=S.plugin.storage[e]??G[e];const i=new Proxy(S.plugin.storage,{get(e,t){return e[t]},set(e,t,n){return e[t]=n,!0}}),z=$.lazy(function(){return Promise.resolve().then(function(){return Q}).catch(function(e){return console.error("[Last.fm] Failed to load settings:",e),{default:function(){return a.React.createElement(h.ScrollView,{style:{flex:1},contentContainerStyle:{padding:16}},a.React.createElement(M,{style:{color:"#ED4245"}},"Failed to load Last.fm settings. Please check your connection and reload Discord."))}}})});let b=0;const H=3,j=5e3;async function y(){try{await D(),b=0}catch(e){console.error("[Last.fm] Initialization error:",e),b++,b=s.MIN_UPDATE_INTERVAL?n("timeInterval",m):p.showToast(`Minimum interval is ${s.MIN_UPDATE_INTERVAL} seconds`,f.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),a.React.createElement(E,{title:"Options"},a.React.createElement(I,{label:"Show 'Listening to' instead of 'Playing'",value:i.listeningTo??s.DEFAULT_SETTINGS.listeningTo,onValueChange:function(r){return n("listeningTo",r)}}),a.React.createElement(I,{label:"Show Timestamp",value:i.showTimestamp??s.DEFAULT_SETTINGS.showTimestamp,onValueChange:function(r){return n("showTimestamp",r)}}),a.React.createElement(I,{label:"Ignore when Spotify is playing",value:i.ignoreSpotify??s.DEFAULT_SETTINGS.ignoreSpotify,onValueChange:function(r){return n("ignoreSpotify",r)}}),a.React.createElement(I,{label:"Verbose Logging",value:i.verboseLogging??s.DEFAULT_SETTINGS.verboseLogging,onValueChange:function(r){return n("verboseLogging",r)}})),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:X}),a.React.createElement(u,{label:"View Changelog",trailing:a.React.createElement(u.Arrow,null),onPress:function(){h.Linking.openURL(s.GITHUB_COMMITS_URL)}}))))}var Q=Object.freeze({__proto__:null,default:J});return T.currentSettings=i,T.default=q,T.pluginState=c,Object.defineProperty(T,"__esModule",{value:!0}),T})({},vendetta,vendetta.storage,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 6da5418..5fc759f 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":"711718bd85cca79b194fa005aac88a30949a2e1739ae010f197cea1ff121a246"} \ 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":"359f4153768e60d0515115770401eb614112415d973a65e9d06bc3fe58065209"} \ No newline at end of file