项目作者: NiveditJain

项目描述 :
Democratic control over the music over the local network
高级语言: Python
项目地址: git://github.com/NiveditJain/muZik.git
创建时间: 2020-09-22T12:09:45Z
项目社区:https://github.com/NiveditJain/muZik

开源协议:Apache License 2.0

下载


Democratic Party Music Control (CLI)
" class="reference-link">
Logo Democratic Party Music Control (CLI)

Python Version
Under Dev
Pull Requests
build passing
visitors


Party GiF

About

The story begins with around 8 friends sitting in a hostel room of
IIT-Jodhpur, trying to find some ideas for a Hackathon (which
eventually was cancelled) and fighting for whose music to play.
Solution? lets Vote. This project aims to serve this use-case.


People connected over the same local network can connect to
it and add their favourite music to the server,
vote (Upvote/Downvote) for the music they like/dislike,
can listen to music from server to their devices and Paaarrrty!


This project also aims to replace small DJs usually in small parties,
with a microcontroller-based local area server running on IPv4 and
connected to large speakers. Giving people in the party democratic
control over music using their mobile phones or any other device
which could be connected to the private local area network.

Current Features

AutoPlay

Server mains a playlist of song in present instance and automatically
plays the highest priority song, priority decided by weight of
upvote and downvote.

Upload Song

Connected clients can add there song to the playlist.

Upvote Song

Connected clients can upvote the song(s) which they like.

Downvote Song

Connected clients can downvote the song(s) which they dislike.

Playlist

Connected clients can view playlist

Local Play

Connected clients can play a song from server on there local machine.

Getting Started

Get Code

Download (clone code) from this repository and add Sever and Client folders to Server and Client machines respectively.

Install Python 3.7.4

On all client machines and server machine install Python 3.7.4. Install from here

Install pip

for windows machines

  1. python get-pip.py

for mac/linux

  1. python3 get-pip.py

Upgrade pip

for windows use

  1. pip install --upgrade pip

for mac/linux

  1. pip3 install --upgrade pip3

Install Dependencies

for windows run

  1. pip install -r requirements.txt

for mac/linux

  1. pip3 install -r requirements.txt

make sure that requirements.txt is in your working directory.

Setting Server

Go to settings.py file inside server (folder) and set all the variables are per requirements, make sure that EXCHANGE_SIZE has same value for server and all clients.

Running Server

Go to directory where you saved server folder and run

for windows run

  1. python server

for mac/linux

  1. python3 server

On successful start you should get something like

Sever Success
Please note the address on which server is running you need to enter it in client files. Ours is running on 192.168.29.229:8080 (highlighted in red).

Setting Clients

Go to settings.py from client folder and make necessary settings make sure that EXCHANGE_SIZE must have same value for all clients and server. Also make sure that you have entered correct address of the server in settings.py (client).


We are now ready to start the clients!

How to Use?

We have made a complete linux styled CLI. Mak sure to run these commands after completing all the above setups and starting server. Also ensure you are running these commands in directory where client folder is placed.

Note : We are writing here commands for Windows for Linux or Mac just replace python with python3, all things would work same like any other CLI interface.

Help

  1. python client --help

or

  1. python client -h

This will will be there to help you, you can run it anytime, it should show you
Help

Upload

use to upload file to the server

  1. python client -op/--operation upload -n/--name [music name] -p/--path [file path]

Note : / denotes or, you can use any one of the flag to specify the parameters.

It will upload the file your music to the server

--n/--name is required, denotes the name for your music

-p/--path is required, denotes the file path of file on your system

List

displays you a list of songs in current playlist, in the format (Name - id - value)

  1. python client -op/--operation list

Playing

will get you the name of song which is currently being played

  1. python client -op/--operation playing

Local Play

will play the song on your local machine, getting file from the server

  1. python client -op/--operation local_playing -id/--id [song id from list]

-id/--id is required, denotes the id of song to play, get id using the list feature

Upvote

to upvote a song use

  1. python client -op/--operation upvote -id/--id [song id to upload]

-id/--id is required

to play the song before upload add the flag -l/--listen

  1. python client -op/--operation upvote -id/--id -l/--listen

it will play the song on your local machine till you press ctrl + c (cmd + c)

Downvote

all working same as upvote just replace upvote to downvote all the commands,eg,

  1. python client -op/--operation downvote -id/--id [song id to upload]

Working

For each communication client sends a appropriate flag to server, which fires related communication functions in both server and client.
Sever Success
Flags Presently in use,
| Flag | Used for indicate |
| :—: | :———————-: |
| $FLAG:00 | DISCONNECT |
| $FLAG:01 | CREATE_OBJ |
| $FLAG:02 | CREATE_UPVOTE |
| $FLAG:03 | CREATE_DOWNVOTE |
| $FLAG:04 | GET_LIST |
| $FLAG:05 | SUCCESS |
| $FLAG:08 | PLAYING |
| $FLAG:06 | NONE |
| $FLAG:09 | LISTEN |

Upload

Upload Working

Upvote/Downvote

Upvote Downvote Working

Playing/List

Playing List Working

Listen

Listen Working

Code

Server

Directory structure

  1. server
  2. |___ __main__.py
  3. |___ flags.py
  4. |___ music.py
  5. |___ request_handler.py
  6. |___ runchecks.py
  7. |___ settings.py
  8. |___ setup.py
  9. |

Dependencies and Responsibilities

File Responsibility Dependent on
settings.py allow user to make necessary settings
runchecks.py checks that all settings are proper settings.py
setup.py make necessary setups settings.py
flags.py contains all necessary flags
music.py contains Music and Playlist Class and running playlist settings.py
request_handler.py handles all communications and plays the appropriate song flags.py, settings.py, music.py, playsound
main.py starts server, fires all triggers and handles threading for requests runchecks.py, setup.py, settings.py, request_handler.py

Client

Directory structure

  1. client
  2. |___ __main__.py
  3. |___ flags.py
  4. |___ client_functions.py
  5. |___ runchecks.py
  6. |___ settings.py
  7. |___ setup.py
  8. |___ utils.py
  9. |

Dependencies and Responsibilities

File Responsibility Dependent on
settings.py allow user to make necessary settings
runchecks.py checks that all settings are proper settings.py
setup.py make necessary setups settings.py
flags.py contains all necessary flags
utils.py provide some additional functionality features settings.py
client_functions.py handles all communications for client flags.py, settings.py, utils.py, playsound
main.py provide CLI interface and start all features runchecks.py, setup.py, client_functions.py

Contributors

Note

  • This project was started at IIT-Jodhpur under guidance of Dr. Ravi Bhandari as course project for CS311-Data Communication, Pre-Final Year, BTech Computer Science and Engineering, Trimester 1 (September - November 2020).
  • We would be further looking to make this a complete working product, to contribute or join us, please send an email on jain.22@iitj.ac.in
  • Beamed Note Symbol on our diagram, does not belongs to any institute or organization.
  • All our images in this ReadMe are made from free images collections from Canva