-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Premier commit avec l'ensemble des fichiers
Provient d'un repository privé.
- Loading branch information
Showing
26 changed files
with
19,244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Blindtest Deezer | ||
|
||
Cette application est liée à votre compte deezer et permet de créer des blindtests à partir de vos playlists privées et des playlists publiques. | ||
Le nombre de blindtests créé est illimité et vous pouvez rejouer autant de fois que vous voulez. Un système de score permet de garder en mémoire les meilleurs performances. | ||
|
||
# Installation | ||
|
||
## Dépendences | ||
|
||
Ce projet est à la fois en Python (version 3+) et en React JS. Vous aurez donc besoin d'avoir installé au préalable sur votre ordinateur Python 3, PIP (Installateur Python), NPM (Installateur JS) | ||
|
||
Vous devrez donc une fois dans la racine du projet inscrire ces commandes : | ||
|
||
``` | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Faire une demande d'application Deezer | ||
|
||
Vous devrez créer une application du côté du développement de [Deezer](https://developers.deezer.com/) | ||
Vous aurez besoin d'un ID de l'application `app`, de sont mot de passe `app_secret` ainsi que d'un token d'accès `access_token`. | ||
Une fois ces 3 données récupérées, mettez-les dans `config.json` à l'endroit prévu (entre les "") | ||
|
||
## Configuration Serveur | ||
|
||
### Localhost | ||
|
||
Si vous souhaitez seulement tester sur votre ordinateur, indiquez `"localhost"` dans `config.json` à l'endroit défini tout en gardant le port 5000. | ||
|
||
### Réseau local | ||
|
||
Si vous souhaitez diffuser à tous les utilisateurs d'un réseau local, lancez le code react : | ||
`npm start` | ||
Récupérez l'ip utilisée qui sera toujours la même temps que vous restez sur ce réseau avec cet ordinateur. | ||
Mettez cet IP dans `config.json` dans `"ip"` | ||
|
||
# Lancer le Serveur | ||
Ouvrez une console de commande, déplacez vous vers la racine du projet avec `cd` puis inscrivez cette commande : | ||
``` | ||
python3 app.py & npm start --prefix deezer-front | ||
``` | ||
|
||
En cas de problème, ouvrez 2 console de commandes : | ||
- l'une à la racine du projet, Linux :`/`, Windows : `\`; | ||
``` | ||
python3 app.py | ||
``` | ||
- l'autre dans le dossier, Linux : `/deezer-front/`, Windows : `\deezer-front\`: | ||
``` | ||
npm start | ||
``` | ||
## Commencer à jouer | ||
|
||
La première fois que vous jouez vous aurez besoin d'accepter la diffusion de média automatiquement. Normalement situé en haut sur la barre de recherche avec un micro ou une caméra. | ||
En effet le jeu nécessite de lancer la musique dès que vous ouvrez la page. | ||
Une fois accepté vous pouvez jouer à l'infini. | ||
|
||
#### Bonne session de jeu. | ||
|
||
## Limitations | ||
|
||
Un blindtest ne peut pas avoir plus de rounds que de chansons. | ||
Une chanson ne peut apparaître qu'une seule fois en tant que réponse. | ||
Si la preview n'existe pas la chanson ne peut pas être la réponse, cependant elle peut tout de même apparaître en tant que choix possible. | ||
Un nombre trop important de score n'est pas prévu pour le moment mais devrait tout de même s'enregistrer normalement. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
from flask import Flask, jsonify, request | ||
from main import ( | ||
blindtest, | ||
create_json_blindtest, | ||
get_score_player, | ||
change_score_player, | ||
getting_playlist_user, | ||
getting_specific_playlists, | ||
get_blindtest, | ||
get_all_playlists, | ||
) | ||
from flask_cors import CORS, cross_origin | ||
import random | ||
import json | ||
|
||
with open("config.json") as config_file: | ||
config_data = json.load(config_file) | ||
|
||
app = Flask(__name__) | ||
|
||
server_settings = config_data["server_settings"] | ||
creds = config_data["deezer_settings"] | ||
|
||
|
||
CORS(app, supports_credentials=True) | ||
|
||
|
||
# Call qui récupère mes playlists pour les avoir rapidement. | ||
@app.route("/get_own_playlists", methods=["GET"]) | ||
@cross_origin(supports_credentials=True) | ||
def get_own_playlists(): | ||
tab_playlists = getting_playlist_user(creds) | ||
return jsonify({"playlists": tab_playlists}) | ||
|
||
|
||
# Call qui récupèrent des playlists selon une query (text) | ||
@app.route("/get_specific", methods=["GET"]) | ||
@cross_origin(supports_credentials=True) | ||
def get_specific(): | ||
query = request.args | ||
print(query["query"]) | ||
tab_playlists = getting_specific_playlists(creds, query["query"]) | ||
return jsonify({"playlists": tab_playlists}) | ||
|
||
|
||
# Call pour créer le JSON du blindtest grâce à l'id de la playlist et le nombre de round demandé | ||
@app.route("/generate_blindtest/<id_playlist>/<nb_round>", methods=["GET"]) | ||
@cross_origin(supports_credentials=True) | ||
def create_blindtest(id_playlist, nb_round): | ||
id_blindtest = random.randint(1, 1000) | ||
error = create_json_blindtest(creds, id_blindtest, id_playlist, int(nb_round)) | ||
if error: | ||
id_blindtest = "Le nombre de round est élevé pour la taille de playlist" | ||
return jsonify({"id": id_blindtest}) | ||
|
||
|
||
# Call qui appelle l'instance de round d'un blindtest | ||
@app.route("/blindtest/<id>/<round>/", methods=["GET"]) | ||
@cross_origin(supports_credentials=True) | ||
def launch_blindtest(id, round): | ||
result = blindtest(id, round) | ||
return jsonify( | ||
{ | ||
"result": result["answer"], | ||
"songs": result["guesses"], | ||
"track": result["track"], | ||
} | ||
) | ||
|
||
|
||
# Call pour récupérer le score d'un joueur | ||
@app.route("/score/<player>/<id>/", methods=["GET", "POST"]) | ||
@cross_origin(supports_credentials=True) | ||
def score(player, id): | ||
if request.method == "GET": | ||
score = get_score_player(player, id) | ||
return jsonify({"score": score}) | ||
if request.method == "POST": | ||
temp = request.get_json() | ||
print(str(temp)) | ||
score = change_score_player(player, temp["score"], id) | ||
return jsonify({"score": score}) | ||
|
||
|
||
# Call qui récupère tous les scores d'un blindtest | ||
@app.route("/get_all_score/<id>/", methods=["GET"]) | ||
@cross_origin(supports_credentials=True) | ||
def get_scores(id): | ||
blindtest = get_blindtest(id) | ||
return jsonify({"scores": blindtest["score"]}) | ||
|
||
|
||
# Call qui récupère tous les scores d'un blindtest | ||
@app.route("/get_all_playlists/", methods=["GET"]) | ||
@cross_origin(supports_credentials=True) | ||
def get_playlists(): | ||
playlists = get_all_playlists() | ||
return jsonify({"playlists": playlists}) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run( | ||
host=server_settings["ip"], | ||
port=server_settings["port"], | ||
debug=True, | ||
threaded=False, | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"server_settings": { | ||
"ip": "http://localhost/", | ||
"port": "5000" | ||
}, | ||
"deezer_settings": { | ||
"app_id": "000000", | ||
"app_secret": "XXX", | ||
"access_token": "XXX" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. | ||
|
||
The page will reload when you make changes.\ | ||
You may also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can't go back!** | ||
|
||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. | ||
|
||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
|
||
### Code Splitting | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) | ||
|
||
### Analyzing the Bundle Size | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) | ||
|
||
### Making a Progressive Web App | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) | ||
|
||
### Advanced Configuration | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) | ||
|
||
### Deployment | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) | ||
|
||
### `npm run build` fails to minify | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
Oops, something went wrong.