Coder Social home page Coder Social logo

stypox / mp3-player Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 66 KB

Plays playlists of mp3s in the desired order (track number, title...)

Python 100.00%
mp3 mp3player mp3-player mp3-tags player music-player music id3 id3-reader music-sorting metadata music-metadata audio audio-player

mp3-player's Introduction

Mp3 player

Plays playlists of MP3s sorted by track number, by title, randomly... Remembers the song being played and the sorting settings before exiting. Can be controlled by pressing keyboard keys.

Useful in combination with my youtube playlist-downloader that saves song metadata.

Keyboard controls

The script uses keyboard input, instead of console input, since it's simpler and more convenient. Note that the console window must be focused for this to work. For example by pressing p the music pauses. This is the complete list of keybindings (| means or):

Abort without saving:                              a | e
Save current song and sorting settings, then exit: s
Pause and resume:                                  p | Enter
Restart: ......................................... r | Home (*)
Next song:                                         Arrow down | Arrow right
Previous song: ................................... Arrow up | Arrow left
Next playlist:                                     Page up
Previous playlist: ............................... Page down

In case the used console doesn't support direct keyboard input, press Enter after pressing a key, just like it was a normal console input.
(*) Home is also known as Start or Beginning, depending on the keyboard.

Sorting

The script provides several ways to sort songs and uses ID3 metadata to get informations about MP3s. The default sort order is by track number and all sort orders have a corresponding code that the script uses to understand them (see Usage):

  • Path: sorts the songs based on their path in alphabetical order a-z (codes: "p" or "path")
  • Title: sorts the songs based on their title in alphabetical order a-z (codes: "t" or "title")
  • Artist: sorts the songs based on their artist in alphabetical order a-z (codes: "a" or "artist")
  • Track number: sorts the songs based on their track number from bottom up (codes: "n" or "number" or "tracknumber")
  • Random: randomly shuffles all the songs (codes: "r" or "random")
  • Modified (prefix): after sorting the songs as requested, this modifier introduces some variability (prefix codes: "m-" or "modified-")

For example: "p" -> sorted by path; "m-number" -> sorted by track number with some variability;

Usage

Choose some directories full of MP3. Every directory is considered a playlist and processed separately from others. Inside every directory a file named mp3-player-settings.txt will be created containing the settings for that directory (for example the song to start with the next time that directory is played). These setting, if existing, will be overwritten by manually provided parameters. The directories I choose are "C:/path/to/songs/" and "./Music/".

Then there are two ways to provide the script with those directories: using a file or using command line arguments (all parameters between [square brackets] are to be considered optional):

Saving directories in file

In the directory the script is executed in create a file named mp3-player-directories.txt. In that file you can insert the directories to be played this way:

DIRECTORY [SORT_ORDER] [START_SONG]
DIRECTORY [SORT_ORDER] [START_SONG]
...

Here "DIRECTORY" represents the directory in which to look for songs; "SORT_ORDER" is optional, must be a sorting code (see Sorting), represents the sort order and defaults to track number order; "START_SONG" is optional, must be an integer (negative integers mean "count from the right"), represents the index of the song to start with and defaults to 0. Save the file and run the script. In this case the file could be:

C:/path/to/songs/ random
./Music/ modified-artist 15

Passing directories as command line arguments

Open a terminal and navigate to the "DIRECTORY" the python script is in (run cd DIRECTORY). Then run python3 FILENAME ARGUMENTS (*) replacing "FILENAME" with the name of the script. "ARGUMENTS" is the list of directories to be played and must be formatted this way:

DIRECTORY [SORT_ORDER] [START_SONG] - ... - DIRECTORY [SORT_ORDER] [START_SONG]

Here "DIRECTORY" represents the directory in which to look for songs; "SORT_ORDER" is optional, must be a sorting code (see Sorting), represents the sort order and defaults to track number order; "START_SONG" is optional, must be an integer (a negative integer means "count from the right"), represents the index of the song to start with and defaults to 0. For example (command line commands):

> cd C:/mp3-player/
> python3 mp3-player.py C:/path/to/songs/ random - ./Music/ modified-artist 15

(*) Note that the command used for Python is not always python3: it could be py, python, python3.6 or others too.

Result

The music should start playing! Now you can use keys to navigate through songs and playlist, see Keyboard controls.

Dependencies

Notes

  • When using random sort order the order of songs is different every time the script is executed.
  • Start song argument is useless when the sort order is random, so it's not saved in mp3-player-settings.txt.
  • When out-of-range indices are provided as "START_SONG" they will be normalized using modulus.

mp3-player's People

Contributors

stypox avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

imammammi

mp3-player's Issues

Add possibility to skip/hide/blacklist a track

E.g. button B could blacklist the track, and pressing U could undo the blacklisting.
Plus: Pressing U after removing something from favourites (from inside the favourites playlist) could undo it.

Also add a "blacklisted" playlist, useful only to un-blacklist channels.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.