Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JustYuuto committed Apr 21, 2024
1 parent fee6126 commit 1e102c3
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 92 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": [
"dist/",
"node_modules/",
"bin/"
],
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"quotes": ["error", "single"],
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
72 changes: 72 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish to GitHub Releases

on:
push:
branches: [master]

jobs:
build-and-deploy:
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache dependencies and build outputs
uses: actions/cache@v2
with:
path: ~/.npm
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}"
restore-keys: ${{ runner.os }}-node-

- name: Install dependencies
run: npm ci

- name: Check version changes
id: check-version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
if git tag | grep -q "v$VERSION"; then
echo "The version has not changed."
echo "::set-output name=changed::false"
else
echo "The version has changed."
echo "::set-output name=changed::true"
fi
- name: Build
run: npm run build

- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: dist/

- name: Extract release notes
id: release-notes
run: |
RELEASE_NOTES=$(awk -v version="$VERSION" '/## \[/{flag=0} /## \['$version'\]/{flag=1} flag' CHANGELOG.md)
echo "RELEASE_NOTES=$RELEASE_NOTES" >> $GITHUB_ENV
- name: Create a GitHub Release
if: steps.check-version.outputs.changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: v${{ env.VERSION }}
draft: false
prerelease: false
body: |
**What's new in this release?**
${{ env.RELEASE_NOTES }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.2.3

* Fixed the RPC not working
* Upgraded packages

## 1.2.2

* Upgraded packages
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
<a href="https://github.com/JustYuuto/deezer-discord-rpc/releases/latest"><img alt="GitHub release (latest by date including pre-releases)" src="https://img.shields.io/github/v/release/justyuuto/deezer-discord-rpc?include_prereleases&label=latest%20release&style=for-the-badge"></a>
<a href="https://github.com/JustYuuto/deezer-discord-rpc/commits"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/w/justyuuto/deezer-discord-rpc?style=for-the-badge"></a>
<hr />
<p>A Discord RPC for showing the music you're listening to on Deezer (like Spotify integration).</p>
<p>If you want to use it on your phone, the app is available on Android: <a href="https://github.com/JustYuuto/deezer-discord-rpc-android/releases/latest">latest release</a></p>
<p>A Discord RPC for showing the music you're listening to on Deezer (like the Spotify integration).</p>
</div>

## Features

* Updates instantly
* Shows the song title, the song artist(s), the album cover (when the mouse is over the album cover the album title is shown) and the song duration
* Shows the song title, the song artist(s), the album cover (when the mouse is over the album cover, the album title is shown) and the song duration
* On the RPC there's a "Listen along" button like on the Spotify integration. This is a link to the song
* An in-app updater
* Can hide the activity if song is not playing
* Can set a "Listening to" status (like Spotify) (**requires your Discord token**)
* Can set a "Listening to" status (**requires your Discord token**)
* Includes an ad-blocker, so it can block Deezer ads, Sentry requests...
* Supports songs, radios, personal songs, podcasts

Expand Down
11 changes: 7 additions & 4 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ const config = {
]
};

const platform = process.argv[2];
if (!builder.Platform[platform.toUpperCase()]) throw new Error(`The platform "${platform}" is not supported for building. Supported: windows, linux, mac`);

builder.build({ targets: builder.Platform[platform.toUpperCase()].createTarget(), config }).then(() => {
builder.build({
config,
// mac: ['dmg'],
win: ['nsis'],
// linux: ['snap', 'deb', 'AppImage'],
x64: true,
}).then(() => {
console.log('\nSetup built in the "dist" folder.');
});
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deezer-discord-rpc",
"version": "1.2.2",
"version": "1.2.3",
"description": "A Discord RPC for Deezer",
"main": "./build/src/index.js",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"run": "yarn build:ts && yarn run copy-assets && yarn start",
"postinstall": "electron-builder install-app-deps",
"lint": "eslint --fix --ext .ts ./src",
"copy-assets": "cpy ./src/img/* ./build/ && cpy ./src/prompt.html ./build/"
"copy-assets": "cpy ./src/img/* ./build/src/img/ && cpy ./src/prompt.html ./build/"
},
"dependencies": {
"@cliqz/adblocker-electron": "^1.26.2",
Expand All @@ -25,13 +25,13 @@
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"cpy-cli": "^4.2.0",
"electron": "^28.1.0",
"electron-builder": "^24.9.1",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"eslint": "^8.56.0",
"fs-extra": "^11.1.1",
"fs-extra": "^11.2.0",
"png-to-ico": "^2.1.4",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
"repository": "https://github.com/JustYuuto/deezer-discord-rpc.git",
"author": {
Expand Down
1 change: 1 addition & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('ipcRenderer', {
Expand Down
6 changes: 4 additions & 2 deletions src/utils/Activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RichPresence } from 'discord.js-selfbot-v13';

export async function setActivity(options: {
client: import('discord-rpc').Client | import('discord.js-selfbot-v13').Client, albumId: number, trackId: string, playing: boolean, timeLeft: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
trackTitle: string, trackArtists: any, albumCover: string, albumTitle: string, app: Electron.App, type: string
}) {
const {
Expand Down Expand Up @@ -71,9 +72,10 @@ export async function setActivity(options: {
.setName('Deezer')
.setDetails(trackTitle)
.setState(trackArtists)
// @ts-ignore
// @ts-expect-error wrong type
.setStartTimestamp(playing && Date.now())
// @ts-ignore
// @ts-expect-error wrong type too
// eslint-disable-next-line no-unexpected-multiline
[isLivestream ? 'setStartTimestamp' : 'setEndTimestamp'](playing && Date.now() + timeLeft)
.setApplicationId(clientId)
.setAssetsLargeImage('mp:'.concat((await RichPresence.getExternal(client, clientId, albumCover, ''))[0].external_asset_path))
Expand Down
4 changes: 1 addition & 3 deletions src/utils/AdBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ export default async function (app: Electron.App, win: Electron.BrowserWindow) {
enableCompression: true
}, {
path: join(app.getPath('userData'), 'engine.bin'),
// @ts-ignore
read: async (...args) => readFileSync(...args),
// @ts-ignore
write: async (...args) => writeFileSync(...args),
});
blocker.enableBlockingInSession(win.webContents.session);
}
}
1 change: 1 addition & 0 deletions src/utils/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function set(app: Electron.App, key: string, value: unknown) {
export function get(app: Electron.App, key?: string) {
const path = getConfigPath(app);
if (!existsSync(path)) writeFileSync(path, '{}');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const data = require(path);
return key ? data[key] : data;
}
Expand Down
11 changes: 5 additions & 6 deletions src/utils/Window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async function updateActivity(app: Electron.App, currentTimeChanged?: boolean) {
const albumName = (!isLivestreamRadio ? dzPlayer.getAlbumTitle() : dzPlayer.getCurrentSong().LIVESTREAM_TITLE) ||
dzPlayer.getCurrentSong()?.SHOW_NAME || playerInfo;
const artists = dzPlayer.getCurrentSong()?.ARTISTS?.map(art => art.ART_NAME)?.join(', ') || dzPlayer.getArtistName() ||
dzPlayer.getCurrentSong()?.SHOW_NAME || playerInfo.split(' · ')[1];
dzPlayer.getCurrentSong()?.SHOW_NAME || playerInfo?.split(' · ')?.[1];
const playing = dzPlayer.isPlaying();
const songTime = Math.floor(dzPlayer.getDuration() * 1000);
const timeLeft = Math.floor(dzPlayer.getRemainingTime() * 1000);
Expand All @@ -171,8 +171,7 @@ async function updateActivity(app: Electron.App, currentTimeChanged?: boolean) {
runJs(code).then(async (r) => {
const result: JSResult = JSON.parse(r);
const realSongTime = result.songTime;
// @ts-ignore
if (!currentTrack?.songTime) currentTrack?.songTime = realSongTime;
if (!currentTrack?.songTime) currentTrack.songTime = realSongTime;
if (
currentTrack?.trackTitle !== result.trackName || currentTrack?.playing !== result.playing || currentTimeChanged === true ||
currentTrack?.songTime !== realSongTime
Expand All @@ -187,11 +186,11 @@ async function updateActivity(app: Electron.App, currentTimeChanged?: boolean) {
else if (currentTimeChanged && currentTimeChanged === true) reason = UpdateReason.MUSIC_TIME_CHANGED;
else if (currentTrack?.songTime !== realSongTime) reason = UpdateReason.MUSIC_NOT_RIGHT_TIME;
log('Activity', 'Updating because', reason);
// @ts-ignore
// @ts-expect-error wrong type
currentTrack = {
trackId: result.trackId,
trackTitle: result.trackName,
trackArtists: result.artists || result.playerType.replace(result.playerType[0], result.playerType[0].toUpperCase()),
trackArtists: result.playerType === 'mod' && !result.artists ? 'Unknown' : result.artists || result.playerType.replace(result.playerType[0], result.playerType[0].toUpperCase()),
albumCover: result.coverUrl,
albumTitle: result.albumName || result.trackName,
playing: result.playing,
Expand Down Expand Up @@ -225,7 +224,7 @@ interface JSResult {
albumId: number,
playing: boolean,
coverUrl?: string,
playerType: 'track' | 'radio' | 'ad',
playerType: 'track' | 'radio' | 'ad' | 'mod',
artists: string,
albumName: string,
isLivestreamRadio: boolean,
Expand Down
Loading

0 comments on commit 1e102c3

Please sign in to comment.