Commit bc4759fc authored by Brian Guadalupe's avatar Brian Guadalupe

Merge branch 'patch-1' into 'master'

Miscellaneous changes

See merge request brian/mymusiclist!14
parents cef7513f 588026ad
...@@ -6,6 +6,7 @@ This is a work in progress as of now... ...@@ -6,6 +6,7 @@ This is a work in progress as of now...
## Prerequisites ## Prerequisites
* Python 2.7/3.4 or later * Python 2.7/3.4 or later
* `virtualenv` (preferred) * `virtualenv` (preferred)
* `musicbrainzngs` (required)
* SQLite3 (for testing) * SQLite3 (for testing)
* Add the `sqlite3` executable in your `PATH` * Add the `sqlite3` executable in your `PATH`
* MySQL (for the final version) * MySQL (for the final version)
...@@ -24,21 +25,13 @@ This assumes both Python and Git have been already installed and added to the `P ...@@ -24,21 +25,13 @@ This assumes both Python and Git have been already installed and added to the `P
* `. `*`path/to/venv/`*`bin/activate` (for Linux/Mac OS) * `. `*`path/to/venv/`*`bin/activate` (for Linux/Mac OS)
5. Install Django using `pip` (inside the virtualenv) 5. Install Django using `pip` (inside the virtualenv)
* `pip install django` * `pip install django`
6. Install musicbrainzngs using `pip` (also inside the virtualenv)
* `pip install musicbrainzngs`
6. Make sure that the `migrations` folder is empty except for the `__init__.py` file 6. Make sure that the `migrations` folder is empty except for the `__init__.py` file
7. Delete the `db.sqlite3` file if it exists 7. Delete the `db.sqlite3` file if it exists
8. Run the following commands (inside the virtualenv): 8. Get the `SQL/freshdb` file then copy it into the root directory
* `python manage.py makemigrations core playlist search tag user` 9. Rename file to db.sqlite3
* `python manage.py migrate` 10. Run the web server
9. Open the `db.sqlite3` file in sqlite3, and run the following commands:
* *`sqlite> `* `.read SQL/sqlite3.sql`
* *`sqlite> `* `.quit`
10. Populate the songs database
* Run `python manage.py shell`
* ~~*`>>> `* `exec(open('./SQL/populate_songs.py').read())`~~ DOESN'T WORK YET!
* Instead, copy everything from `populate_songs.py` and then paste into the shell
* *`>>> `* `run()`
* This works for now...
11. Run the web server
* `python manage.py runserver` * `python manage.py runserver`
12. (Optional) Create admin account to access the admin interface 11. (Optional) Create admin account to access the admin interface
* `python manage.py createsuperuser` * `python manage.py createsuperuser`
\ No newline at end of file
=========DO NOT RUN===========
mymusiclist.sql
convert
extract.sql
Assuming you have sqlite3 installed and Django setup with migrations,
While in same directory as db.sqlite3, run:
Sqlite3
.open db.sqlite3
.read SQL/sqlite3.sql
If you're not yet migrated, then do this first:
python manage.py makemigrations core
python manage.py migrate
Now you can view tables with .tables and run sql statements
Assuming you have mysql installed, run:
Mysql
Use mymusiclist
Source sql/mysql.sql
File added
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import pprint import pprint
import musicbrainzngs import musicbrainzngs
from musicbrainzngs import ResponseError from musicbrainzngs import ResponseError
from musicbrainzngs import NetworkError
from core.models import Album from core.models import Album
pp = pprint.PrettyPrinter(indent=4) pp = pprint.PrettyPrinter(indent=4)
...@@ -18,12 +19,12 @@ def verifyAlbumArt(album, artist): ...@@ -18,12 +19,12 @@ def verifyAlbumArt(album, artist):
def fetchAlbumArt(name, artist): def fetchAlbumArt(name, artist):
debug("GET " + name + " " + artist) debug("GET " + name + " " + artist)
results = musicbrainzngs.search_release_groups(name, limit = 3, artistname=artist, primarytype="album")
#pp.pprint(results['release-group-list'])
results = results['release-group-list']
resultid = results[0]['id']
debug("ID = " + resultid)
try: try:
results = musicbrainzngs.search_release_groups(name, limit = 3, artistname=artist, primarytype="album")
#pp.pprint(results['release-group-list'])
results = results['release-group-list']
resultid = results[0]['id']
debug("ID = " + resultid)
imagelist = musicbrainzngs.get_release_group_image_list(resultid) imagelist = musicbrainzngs.get_release_group_image_list(resultid)
except ResponseError: except ResponseError:
debug("No image found.") debug("No image found.")
......
...@@ -24,7 +24,23 @@ ...@@ -24,7 +24,23 @@
Year: {{i.year}} </p> Year: {{i.year}} </p>
</div> </div>
<!-- ... -->
{% if request.user.is_authenticated %}
<!-- ... -->
<div class="w3-dropdown-hover">
<button id="search_type" class="w3-button" style="width:200px; text-align: left;"><i class="fa fa-caret-down"></i> </button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<button class=" w3-bar-item w3-button">Update existing playlist</button>
<button onclick="alert('{{type}} id is {{i.id}}')">Show {{type}}</button>
<button class=" w3-bar-item w3-button">Create new playlist</button>
</div>
</div>
<!-- ... -->
{% endif %}
<!-- ... -->
{% endif %} {% endif %}
...@@ -41,7 +57,22 @@ ...@@ -41,7 +57,22 @@
{% endif %} </p> {% endif %} </p>
{% endfor %} {% endfor %}
</div> </div>
<!-- ... -->
{% if request.user.is_authenticated %}
<!-- ... -->
<div class="w3-dropdown-hover">
<button id="search_type" class="w3-button" style="width:200px; text-align: left;"><i class="fa fa-caret-down"></i> </button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<button class=" w3-bar-item w3-button">Update existing playlist</button>
<button onclick="alert('{{type}} id is {{i.id}}')">Show {{type}}</button>
<button class=" w3-bar-item w3-button">Create new playlist</button>
</div>
</div>
<!-- ... -->
{% endif %}
<!-- ... -->
{% endif %} {% endif %}
...@@ -56,6 +87,22 @@ ...@@ -56,6 +87,22 @@
<p>Artist: <a href="/artist/{{i.artist.id}}">{{i.artist.name}}</a><br> <p>Artist: <a href="/artist/{{i.artist.id}}">{{i.artist.name}}</a><br>
Year: {{i.album.year}} </p> Year: {{i.album.year}} </p>
</div> </div>
<!-- ... -->
{% if request.user.is_authenticated %}
<!-- ... -->
<div class="w3-dropdown-hover">
<button id="search_type" class="w3-button" style="width:200px; text-align: left;"><i class="fa fa-caret-down"></i> </button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<button class=" w3-bar-item w3-button">Update existing playlist</button>
<button onclick="alert('{{type}} id is {{i.id}}')">Show {{type}}</button>
<button class=" w3-bar-item w3-button">Create new playlist</button>
</div>
</div>
<!-- ... -->
{% endif %}
<!-- ... -->
{% endif %} {% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment