fix setup.py, simplify Pipenv use

This commit is contained in:
Matt Behrens 2018-01-24 20:49:30 -05:00
parent 8f3f391b6d
commit a2c9684078
4 changed files with 25 additions and 24 deletions

View file

@ -6,13 +6,13 @@ A Mastodon client that automatically plays your friends' music as they toot link
You'll need `ffplay` from [FFmpeg](https://ffmpeg.org/) to actually play music. On macOS, `ffplay` is part of the Homebrew ffmpeg package, but you need to build it with `brew install ffmpeg --with-sdl2`. You'll need `ffplay` from [FFmpeg](https://ffmpeg.org/) to actually play music. On macOS, `ffplay` is part of the Homebrew ffmpeg package, but you need to build it with `brew install ffmpeg --with-sdl2`.
Edit `stream.py` so it points to your Mastodon instance. Edit `API_BASE_URL` at the top of `fediplay.py` so it points to your Mastodon instance.
Use `pipenv install --dev` from [Pipenv](https://docs.pipenv.org/) to install the Python dependencies and set up the package with a `stream` executable. Use `pipenv install` from [Pipenv](https://docs.pipenv.org/) to install the Python dependencies.
## Streaming ## Streaming
Use `pipenv run stream` to start the stream. You'll need to log in the first time. Use `pipenv run python -m fediplay` to start the stream. You'll need to log in the first time.
Toots that include the hashtag #fediplay and have as their first link something that [youtube-dl](https://rg3.github.io/youtube-dl/) can play, will! Toots that include the hashtag #fediplay and have as their first link something that [youtube-dl](https://rg3.github.io/youtube-dl/) can play, will!

View file

@ -1,3 +1,5 @@
API_BASE_URL = 'https://cybre.space'
from subprocess import run from subprocess import run
from threading import Thread, Lock from threading import Thread, Lock
@ -26,6 +28,7 @@ class Queue(object):
def run_thread(filename, cb_complete): def run_thread(filename, cb_complete):
print('==> Playing', filename) print('==> Playing', filename)
run(['ffplay', '-v', '0', '-nostats', '-hide_banner', '-autoexit', '-nodisp', filename]) run(['ffplay', '-v', '0', '-nostats', '-hide_banner', '-autoexit', '-nodisp', filename])
print('==> Playback complete')
cb_complete() cb_complete()
thread = Thread(target=run_thread, args=(filename, cb_complete)) thread = Thread(target=run_thread, args=(filename, cb_complete))
@ -90,3 +93,21 @@ def extract_links(toot):
all_links = html.cssselect('a') all_links = html.cssselect('a')
return [link.attrib['href'] for link in all_links if not has_external_link_class(link.attrib.get('class', ''))] return [link.attrib['href'] for link in all_links if not has_external_link_class(link.attrib.get('class', ''))]
def main():
import os
from getpass import getpass
if not os.path.exists('clientcred.secret'):
print('==> No clientcred.secret; registering application')
register(API_BASE_URL)
if not os.path.exists('usercred.secret'):
print('==> No usercred.secret; logging in')
email = input('Email: ')
password = getpass('Password: ')
login(API_BASE_URL, email, password)
stream(API_BASE_URL)
if __name__ == '__main__':
main()

View file

@ -11,7 +11,7 @@ setup(
], ],
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'stream = stream:run' 'fediplay = fediplay:main'
] ]
} }
) )

View file

@ -1,20 +0,0 @@
#!/usr/bin/env python
API_BASE_URL = 'https://cybre.space'
import os
from getpass import getpass
from fediplay import register, login, stream
if not os.path.exists('clientcred.secret'):
register(API_BASE_URL)
if not os.path.exists('usercred.secret'):
email = input('Email: ')
password = getpass('Password: ')
login(API_BASE_URL, email, password)
def run():
stream(API_BASE_URL)