Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: import playlists from external libraries #27

Merged
merged 7 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"id": "command",
"type": "pickString",
"description": "Which command do you want to run?",
"options": ["smart", "relocate", "help"],
"options": ["smart", "relocate", "import-ext", "help"],
"default": "smart"
}
]
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"SHAYDED",
"Venmo",
"dedupe",
"destructure",
"enjinn",
"execa",
"keyby",
Expand All @@ -17,7 +18,8 @@
"metas",
"nsis",
"rshea",
"shallwefootball"
"shallwefootball",
"tempfs"
],
"files.exclude": {
"lib": true,
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Library relocation
- Relocate missing tracks
- Provide a folder to search for tracks in
- Imports playlists created on smart consoles like the Prime 4 or SC6000
- Automatically backs up library before running
- Supports Engine 1.6.x
- Cross platform
Expand Down Expand Up @@ -62,6 +63,8 @@ $ npm install -g enjinn@latest

ENJINN is a command line app, which means you will need to run it from your terminal.

> ⚠️ **Engine must be closed when running ENJINN!**

Depending on your OS, here's how you can open up a terminal:

#### Windows 10
Expand All @@ -76,12 +79,14 @@ Depending on your OS, here's how you can open up a terminal:

Once your terminal is open, simply run the `enjinn` command to view the help info.

> Only type the text _after_ the `$`
_Only type the text after the `$`_

```
$ enjinn
```

> To stop ENJINN in the middle of running a command, press `ctrl+c`.

[Available commands](#-commands)

### Activating
Expand All @@ -102,7 +107,7 @@ The free version has several restrictions:

- Smart playlists: Up to 5 playlists, no nested filters
- Relocate: Basic macthing only. Premium will add the ability to fix individual tracks as well as handle renamed files.
- Playlist import: Will be premium only.
- Playlist import: Premium only.

### Library configuration

Expand All @@ -121,6 +126,7 @@ In the future, you'll be able to specify multiple Engine libraries and even swit

- 🧠 [`smart` - Generate smart playlists](#-smart)
- 🔍 [`relocate` - Relocate missing tracks](#-relocate)
- 📼 [`import-ext` - Import playlists from external libraries](#-import-ext)

### 🧠 Smart

Expand All @@ -132,7 +138,7 @@ $ enjinn smart

To configure the smart playlists, place a file called `enjinn.yaml` in your Engine library folder. See the [examples](examples/enjinn.example.yaml) to learn how to define playlists.

If a playlist already exists (at the root level) with the same name as one of your smart playlists **IT WILL BE OVERWRITTEN**. In most cases this is desired, as you'll want to update your smart playlists.
If a playlist already exists with the same name as one of your smart playlists **IT WILL BE OVERWRITTEN**. In most cases this is desired, as you'll want to update your smart playlists.

### 🔍 Relocate

Expand All @@ -145,3 +151,13 @@ $ enjinn relocate
ENJINN will scan your library for tracks that are missing on disk. It will then ask you to specify a folder to search for your tracks in. It will also search up to 5 subfolders deep. After searching, it will print out the relocated tracks and their new paths.

Currently, the filenames have to be the same, but soon you'll be able to specify rules for matching filenames as well as rename individual files.

### 📼 Import External

Imports playlists created on smart consoles like the Prime 4 or SC6000.

```
$ enjinn import-ext
```

ENJINN will look for USB drives that contain Engine libraries. It will ask you to select which drive to import from. After selecting a drive, it will ask you which playlists you want to import.
46 changes: 45 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"js-yaml": "4.1.0",
"knex": "0.95.4",
"lodash": "4.17.21",
"node-disk-info": "1.3.0",
"node-fetch": "2.6.1",
"node-rsa": "1.1.1",
"ora": "5.4.0",
Expand Down
17 changes: 17 additions & 0 deletions src/base-commands/base-engine-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,21 @@ export abstract class BaseEngineCommand extends Command {
this.log(`${indentStr}${(chalk as any)[color](t.path)}`),
);
}

protected logPlaylistsWithTrackCount(
playlists: engine.PlaylistInput[],
{ indent = 4 }: { indent?: number } = {},
) {
const indentStr = ' '.repeat(indent);
playlists.forEach(({ title, tracks }) => {
const numTracks = tracks.length;
if (numTracks) {
this.log(
chalk`${indentStr}{blue ${title}} [{green ${numTracks.toString()}} tracks]`,
);
} else {
this.log(chalk`${indentStr}{blue ${title}} [{yellow 0} tracks]`);
}
});
}
}
Loading