Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miohtama/LibertyMusicStore
Bitcoin-based MP3 store which artists can add to their own websites
https://github.com/miohtama/LibertyMusicStore
Last synced: about 2 months ago
JSON representation
Bitcoin-based MP3 store which artists can add to their own websites
- Host: GitHub
- URL: https://github.com/miohtama/LibertyMusicStore
- Owner: miohtama
- License: other
- Created: 2014-06-03T22:26:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-22T09:59:12.000Z (about 4 years ago)
- Last Synced: 2024-11-20T17:25:19.039Z (2 months ago)
- Language: Python
- Homepage: https://libertymusicstore.net/
- Size: 5.48 MB
- Stars: 31
- Watchers: 8
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
.. contents:: :local:
Introduction
---------------`Liberty Music Store is a prototype MP3 store taking Bitcoin payments. `_
The project is 100% open source. You can use this as an example project for your Django and Bitcoin services.
Stack
------* `Python 3.4 `_ - core programming language
* `Django `_ - Python web framework
* `Bootstrap `_ - Layout
* `uWSGI `_ - web server
* `Nginx `_ - web server
* PostgreSQL / SQLite - database
* Redis - database (sessions, task queue)
* `Supervisor `_ - process launch and management
* `cryptoassets.core `_ / `cryptoassets.django `_ - Bitcoin payment handling
* `huey `_ - asynchronous and background tasks
* `bitcoinaddress.js `_ - Bitcoin address interaction in web browser
* `bitcoinprices.js `_ - real-time currency conversion
* `Sentry `_ - logging
* `Duplicity `_ - backups
* `ffmpeg `_ - audio processing
Development environment setup
------------------------------PostgreSQL is recommened. SQLite 3 won't work because it locks the full database on a write, causing conflict with page requests, AJAX requests and cryptoassets helper service accessing the database at the same moment.
Checkout::
git checkout
git submodule update --init --recursiveSetup virtualenv::
export PATH=/usr/local/mysql/bin:$PATH
virtualenv-2.7 venv
source venv/bin/activate
# https://bitbucket.org/nicfit/eyed3/issue/80/pypi-hosted-release
pip install --allow-all-external -r requirements.txtExample ``local_settings.py`` for development::
import os
import sysALLOWED_HOSTS = ["localhost:8000", "localhost:8090", "libertymusicstore.net:9999"]
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
RECAPTCHA_PUBLIC_KEY = 'x'
RECAPTCHA_PRIVATE_KEY = 'y'
RECAPTCHA_USE_SSL = TruePUBLIC_URL = "http://localhost:8000"
# FB test settings
if "runsslserver" in sys.argv:
os.environ["HTTPS"] = "on"
SITE_URL = "https://libertymusicstore.net:9999"
else:
SITE_URL = "http://localhost:8000"HUEY = {
'backend': 'huey.backends.redis_backend', # required.
'name': 'Huey Redis',
'connection': {'host': 'localhost', 'port': 6379},
'always_eager': True, # Defaults to False when running via manage.py run_huey
'consumer_options': {'workers': 3},
}# Facebook development
FACEBOOK_SECRET_KEY = "x"#from cryptoassets.core.coin.bitcoin.models import BitcoinWallet
#PAYMENT_WALLET_CLASS = BitcoinWallet# TESTNET settings
CRYPTOASSETS = {# You can use a separate database for cryptoassets,
# or share the Django database. In any case, cryptoassets
# will use a separate db connection.
"database": {
"url": "postgresql://localhost/cryptoassets_copy",
"echo": False,
},"coins": {
# Locally running bitcoind in testnet
"btc": {
"backend": {
"class": "cryptoassets.core.backend.blockio.BlockIo",
"api_key": "x",
"network": "btctest",
"pin": "x",
# Cryptoassets helper process will use this UNIX named pipe to communicate
# with bitcoind
"walletnotify": {
"class": "cryptoassets.core.backend.sochainwalletnotify.SochainWalletNotifyHandler",
"pusher_app_key": "x"
},
}
},
},# Bind cryptoassets.core event handler to Django dispacth wrapper
"events": {
"django": {
"class": "cryptoassets.core.event.python.InProcessEventHandler",
"callback": "cryptoassets.django.incoming.handle_tx_update"
}
},"status_server": {
"ip": "127.0.0.1",
"port": 9001
}
}Setup empty database::
python manage.py syncdb
python manage.py migrate tatianstore# This creates some initial users and stuff
# This scripts reads stuff from sample CD folder (copyrighted),
# so ask for a copy
echo "exec(open('./bin/populate.py').read())" | python manage.py shellFix ``readline`` package on OSX::
easy_install -U readline
Start the server::
python manage.py runserver
Production setup on Ubuntu
----------------------------Install::
apt-get install postgresql libncurses5-dev redis-server python-virtualenv openssl
apt-get install build-essential git-core libfreetype6-dev libmemcached-dev libxml2-dev libxslt1-dev libjpeg-dev libpng12-dev gettext gitCreate databases::
sudo -i -u postgresq
createdb cryptoassets_production
createdb tatianastore_productionCreate venv::
python3.4 -m venv --copies venv
... TODO
FFMPEG
--------FFMPEG is required in order to create the prelisten samples.
Installing on OSX::
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
Running tests
----------------Ex::
python manage.py test tatianastore --settings=tatianastore.test_settings
Production setup
-----------------Dependencies::
apt-get install supervisor postgresql postgresql-server-dev-all
source /srv/django/tatianastore/venv/bin/activate
pip install psycopg2ffmpeg::
cd /tmp
wget http://johnvansickle.com/ffmpeg/releases/ffmpeg-2.2.1-64bit-static.tar.bz2
tar -xf ffmpeg-2.2.1-64bit-static.tar.bz2
mv ffmpeg-2.2.1-64bit-static/ffmpeg /usr/local/binDeployment::
ssh tatianastore
git pull && supervisorctl restart tatianastore_uwsgiTaking SQL dump::
sudo -u postgres pg_dump tatianastore > backup.sql
Restoring SQL dump::
sudo -u postgres psql -d tatianastore_production -f backup.sql
Creatin htpasswd file for the status server::
apt-get install apache2-utils
htpasswd -c status.htpasswd statusMore
* https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
* http://od-eon.com/blogs/calvin/postgresql-cheat-sheet-beginners/
Facebook app testing
----------------------TODO: deprecated
Register a faux app on Facebook.
Use `runsslserver` to run a local development server.
Tunnel localhost:8000 to remoto IP:9999.
Set this publicly accessible port to your FB app settings.
Making a dummy BTC payment when running in FB test mode::
wget -S --no-check-certificate --output-document="-" "https://libertymusicstore.net:9999/blockchain_received/?transaction_hash=x&value=10000&address=1CAEmjdasqskBEJMsCeY9wUeBuofiw21cA"
Other
-----Codename ``tatianastore`` is used through the project.
``test-song.mp3`` is *I dunno* by *Grapes*.
* http://ccmixter.org/files/grapes/16626
Author
------Mikko Ohtamaa (`blog `_, `Facebook `_, `Twitter `_, `Google+ `_)