Compare commits
7 Commits
2359ffe922
...
2301adac39
Author | SHA1 | Date |
---|---|---|
localhost_frssoft | 2301adac39 | |
localhost_frssoft | 6c7bcf476f | |
localhost_frssoft | 8e79357287 | |
localhost_frssoft | c9f9871e26 | |
localhost_frssoft | a99cd9fd57 | |
localhost_frssoft | 230d92f399 | |
localhost_frssoft | e7a57fc637 |
9
MIRRORS
9
MIRRORS
|
@ -1,6 +1,5 @@
|
||||||
# Avalaible mirrors
|
# Avalaible mirrors
|
||||||
https://inex.dev/localhost_frssoft/funkwhale-cli.git
|
https://inex.dev/localhost_frssoft/funkwlmpv.git
|
||||||
|- https://git.vector1.dev/localhost_frssoft/funkwhale-cli
|
|- https://git.vector1.dev/localhost_frssoft/funkwlmpv
|
||||||
https://git.macaw.me/localhost_frssoft/funkwhale-cli.git
|
https://git.macaw.me/localhost_frssoft/funkwlmpv.git
|
||||||
https://code.criminallycute.fi/localhost_frssoft/funkwhale-cli.git
|
https://code.criminallycute.fi/localhost_frssoft/funkwlmpv.git
|
||||||
https://git.poridge.club/localhost_frssoft/funkwhale-cli.git
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# funkwhale-cli
|
# funkwlmpv
|
||||||
Just for fun. A simple TUI media player for FunkWhale instances. Writen on python
|
Just for fun. A simple TUI media player for FunkWhale instances. Writen on python
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
@ -21,7 +21,7 @@ Python dependencies:
|
||||||
Optional: brotli
|
Optional: brotli
|
||||||
|
|
||||||
### About cache folder
|
### About cache folder
|
||||||
funkwhale-cli has to cache tracks before playing (default disabled "enable_persistent_cache"). Cache is persistent and you should manage it manually because the (script/program) can't clean it automatically.
|
funkwlmpv has to cache tracks before playing (default disabled "enable_persistent_cache"). Cache is persistent and you should manage it manually because the (script/program) can't clean it automatically.
|
||||||
Cache structure: cache/domain.tld/[track uuid]
|
Cache structure: cache/domain.tld/[track uuid]
|
||||||
You can play tracks offline, example: mpv --shuffle cache/*/*
|
You can play tracks offline, example: mpv --shuffle cache/*/*
|
||||||
cache_helper.sh - it might be useful for compression cache (lossy: vorbis 128 kbps, no thumbnail)
|
cache_helper.sh - it might be useful for compression cache (lossy: vorbis 128 kbps, no thumbnail)
|
||||||
|
|
|
@ -94,7 +94,7 @@ def main():
|
||||||
print(f'''
|
print(f'''
|
||||||
If You want sign in, please visit:
|
If You want sign in, please visit:
|
||||||
https://{current_instance.instance}/settings/applications/new
|
https://{current_instance.instance}/settings/applications/new
|
||||||
And fill Name funkwhale-cli
|
And fill Name funkwlmpv
|
||||||
Scopes:
|
Scopes:
|
||||||
Read | Write (optional):
|
Read | Write (optional):
|
||||||
write:libraries
|
write:libraries
|
|
@ -0,0 +1,39 @@
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from src.mpv_control import player
|
||||||
|
from loguru import logger
|
||||||
|
'''Warning! This module can be very battery drain'''
|
||||||
|
|
||||||
|
|
||||||
|
@logger.catch
|
||||||
|
def handle_vol_lvl_as_switch_track():
|
||||||
|
volume_diff = []
|
||||||
|
while True:
|
||||||
|
debug_time = time.time()
|
||||||
|
volume = subprocess.Popen("termux-volume", stdout=subprocess.PIPE).stdout
|
||||||
|
json_volume = json.loads(volume.read())
|
||||||
|
for i in json_volume:
|
||||||
|
if i['stream'] == 'music':
|
||||||
|
volume_diff.append(i['volume'])
|
||||||
|
if len(volume_diff) == 2:
|
||||||
|
before, after = volume_diff
|
||||||
|
difference = after - before
|
||||||
|
if difference == 2:
|
||||||
|
try:
|
||||||
|
player.playlist_next()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
os.system(f'termux-volume music {before}')
|
||||||
|
volume_diff = []
|
||||||
|
debug_time2 = time.time()
|
||||||
|
total = debug_time2 - debug_time
|
||||||
|
print(total)
|
||||||
|
time.sleep(0.300)
|
||||||
|
|
||||||
|
|
||||||
|
handle_vol_lvl = threading.Thread(
|
||||||
|
target=handle_vol_lvl_as_switch_track, daemon=True)
|
||||||
|
handle_vol_lvl.start()
|
|
@ -32,7 +32,7 @@ class current_instance:
|
||||||
s = requests.Session()
|
s = requests.Session()
|
||||||
s.headers.update({
|
s.headers.update({
|
||||||
"Accept-encoding": 'gzip, br, deflate',
|
"Accept-encoding": 'gzip, br, deflate',
|
||||||
"User-Agent": "funkwhale-cli/latest-commit; +https://git.phreedom.club/localhost_frssoft/funkwhale-cli"
|
"User-Agent": "funkwlmpv/latest-commit; +https://git.phreedom.club/localhost_frssoft/funkwlmpv"
|
||||||
})
|
})
|
||||||
instance = get_config('instance')
|
instance = get_config('instance')
|
||||||
token = auth.get(instance)
|
token = auth.get(instance)
|
||||||
|
|
|
@ -77,7 +77,7 @@ def fetch_instances_nodeinfo_and_avalaibility(instances):
|
||||||
return requests.get('https://' + instance + '/api/v1/instance/nodeinfo/2.0/',
|
return requests.get('https://' + instance + '/api/v1/instance/nodeinfo/2.0/',
|
||||||
headers={
|
headers={
|
||||||
'Accept-Encoding': 'gzip, brotli, deflate',
|
'Accept-Encoding': 'gzip, brotli, deflate',
|
||||||
'User-Agent': 'funkwhale-cli/latest-commit; +https://git.phreedom.club/localhost_frssoft/funkwhale-cli'},
|
'User-Agent': 'funkwlmpv/latest-commit; +https://git.phreedom.club/localhost_frssoft/funkwlmpv'},
|
||||||
timeout=10).json()
|
timeout=10).json()
|
||||||
|
|
||||||
with concurrent.futures.ThreadPoolExecutor() as executor: # optimally defined number of threads
|
with concurrent.futures.ThreadPoolExecutor() as executor: # optimally defined number of threads
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from src.fw_api import get_favorires_tracks, get_recently_listened, get_audio_file
|
from src.fw_api import get_favorires_tracks, get_recently_listened, get_audio_file
|
||||||
from src.fw_api_hints import hint_scope
|
from src.fw_api_hints import hint_scope
|
||||||
from src.mpv_control import player, player_menu, track_url_to_uuid, player_fw_storage
|
from src.mpv_control import player, player_menu, track_url_to_uuid, player_fw_storage, play_track
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
@ -54,14 +54,3 @@ def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False)
|
||||||
else:
|
else:
|
||||||
play_track(track=tracks_results[int(
|
play_track(track=tracks_results[int(
|
||||||
select[0].split('.', 1)[0])]['track'])
|
select[0].split('.', 1)[0])]['track'])
|
||||||
|
|
||||||
|
|
||||||
def play_track(track, multi=False):
|
|
||||||
listen_url = get_audio_file(track['listen_url'], True)
|
|
||||||
player_fw_storage.storage[track_url_to_uuid(listen_url)] = track
|
|
||||||
if multi:
|
|
||||||
player.loadfile(listen_url, 'append-play')
|
|
||||||
else:
|
|
||||||
player.loadfile(listen_url, 'append-play')
|
|
||||||
track_name = track.get('title')
|
|
||||||
player_menu(f"{track_name} playing...", player_fw_storage.storage)
|
|
||||||
|
|
|
@ -49,10 +49,13 @@ def list_tracks(pg=None, search=None, tag=None, library=None):
|
||||||
for i in tracks_results:
|
for i in tracks_results:
|
||||||
play_track(track=i, multi=True)
|
play_track(track=i, multi=True)
|
||||||
elif select == 'Play all pages':
|
elif select == 'Play all pages':
|
||||||
if tracks_count > 1000:
|
if tracks_count > 500:
|
||||||
yn = input('WARNING: you really want add more than 1000 tracks? (y/[n])\n').lower()
|
yn = input('WARNING: you really want add more than 500 tracks? (y/[n] or number of tracks)\n').lower()
|
||||||
if yn != 'y':
|
try:
|
||||||
return
|
tracks_count = int(yn)
|
||||||
|
except:
|
||||||
|
if yn != 'y':
|
||||||
|
return
|
||||||
count_loaded = 0
|
count_loaded = 0
|
||||||
while tracks_count > count_loaded:
|
while tracks_count > count_loaded:
|
||||||
for i in tracks_results:
|
for i in tracks_results:
|
||||||
|
|
|
@ -23,11 +23,13 @@ player.ytdl = False # Prevent attempts load track with yt-dlp
|
||||||
player.volume = get_config('mpv_volume')
|
player.volume = get_config('mpv_volume')
|
||||||
player.prefetch_playlist = get_config('prefetch_playlist')
|
player.prefetch_playlist = get_config('prefetch_playlist')
|
||||||
show_like_button = get_config('show_like_button')
|
show_like_button = get_config('show_like_button')
|
||||||
track_activity_history = get_config('track_activity_history')
|
|
||||||
share_to_fediverse_token = get_config('share_to_fediverse_token')
|
share_to_fediverse_token = get_config('share_to_fediverse_token')
|
||||||
share_to_fediverse_instance = get_config('share_to_fediverse_instance')
|
share_to_fediverse_instance = get_config('share_to_fediverse_instance')
|
||||||
shuffle = False
|
shuffle = False
|
||||||
|
|
||||||
|
if get_config('termux_handle_track_switch_by_volume'):
|
||||||
|
import src.android_termux_api
|
||||||
|
|
||||||
|
|
||||||
class player_fw_storage:
|
class player_fw_storage:
|
||||||
storage = {}
|
storage = {}
|
||||||
|
@ -70,7 +72,7 @@ def send_listen_activity():
|
||||||
tags = ' '.join(tags)
|
tags = ' '.join(tags)
|
||||||
if tags == []:
|
if tags == []:
|
||||||
tags = ''
|
tags = ''
|
||||||
status_obj = {'spoiler_text': 'funkwhale-cli music share',
|
status_obj = {'spoiler_text': 'funkwlmpv music share',
|
||||||
'visibility': 'unlisted',
|
'visibility': 'unlisted',
|
||||||
'status': f'🎧 {artist} - {album} - {title}\n{fid}\n#NowPlaying {tags}'}
|
'status': f'🎧 {artist} - {album} - {title}\n{fid}\n#NowPlaying {tags}'}
|
||||||
requests.post(f'https://{share_to_fediverse_instance}/api/v1/statuses',
|
requests.post(f'https://{share_to_fediverse_instance}/api/v1/statuses',
|
||||||
|
|
|
@ -44,7 +44,8 @@ default_conf = {
|
||||||
'enable_persistent_cache': False,
|
'enable_persistent_cache': False,
|
||||||
'mpv_volume': 100,
|
'mpv_volume': 100,
|
||||||
'show_like_button': True,
|
'show_like_button': True,
|
||||||
'show_artist_name_in_albums': False
|
'show_artist_name_in_albums': False,
|
||||||
|
'termux_handle_track_switch_by_volume': False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue