diff --git a/api/funkwhale_api/__init__.py b/api/funkwhale_api/__init__.py index c46b89cc90dbd429220a9792dfd84b2d9654d530..0168bc25af3889c3fd06ef2ae9ba55e813da09a9 100644 --- a/api/funkwhale_api/__init__.py +++ b/api/funkwhale_api/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -__version__ = '0.2.1' +__version__ = '0.2.2' __version_info__ = tuple([int(num) if num.isdigit() else num for num in __version__.replace('-', '.', 1).split('.')]) diff --git a/api/funkwhale_api/music/tests/factories.py b/api/funkwhale_api/music/tests/factories.py index dfa7a75e2814c82e276f692da07d1411da2b3e95..d4ec048101984419b5b1459943be5998f43f261a 100644 --- a/api/funkwhale_api/music/tests/factories.py +++ b/api/funkwhale_api/music/tests/factories.py @@ -1,4 +1,7 @@ import factory +import os + +SAMPLES_PATH = os.path.dirname(os.path.abspath(__file__)) class ArtistFactory(factory.django.DjangoModelFactory): @@ -33,7 +36,8 @@ class TrackFactory(factory.django.DjangoModelFactory): class TrackFileFactory(factory.django.DjangoModelFactory): track = factory.SubFactory(TrackFactory) - audio_file = factory.django.FileField() + audio_file = factory.django.FileField( + from_path=os.path.join(SAMPLES_PATH, 'test.ogg')) class Meta: model = 'music.TrackFile' diff --git a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py index 8a99156cb0c477bd371910ef1bbb0a193a2bf52b..a34e36b4b322753a38928545bd30cebdc83434f5 100644 --- a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py +++ b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py @@ -29,7 +29,17 @@ class Command(BaseCommand): def handle(self, *args, **options): # self.stdout.write(self.style.SUCCESS('Successfully closed poll "%s"' % poll_id)) - matching = glob.glob(options['path'], recursive=options['recursive']) + + # Recursive is supported only on Python 3.5+, so we pass the option + # only if it's True to avoid breaking on older versions of Python + glob_kwargs = {} + if options['recursive']: + glob_kwargs['recursive'] = True + try: + matching = glob.glob(options['path'], **glob_kwargs) + except TypeError: + raise Exception('You need Python 3.5 to use the --recursive flag') + self.stdout.write('This will import {} files matching this pattern: {}'.format( len(matching), options['path'])) diff --git a/front/package.json b/front/package.json index 7cec50319a142649dedfb00645418b195c9bf339..55e773fba7b52c6d61655d4e1e80c71349203457 100644 --- a/front/package.json +++ b/front/package.json @@ -18,6 +18,7 @@ "js-logger": "^1.3.0", "semantic-ui-css": "^2.2.10", "vue": "^2.3.3", + "vue-global-events": "^1.0.2", "vue-resource": "^1.3.4", "vue-router": "^2.3.1", "vuedraggable": "^2.14.1" diff --git a/front/src/audio/queue.js b/front/src/audio/queue.js index 25b27f00ea7e677ee9d4973ae876413488cbb17a..77fe6bf2bc89bf0f9fc114b52f7512f9ea19ef94 100644 --- a/front/src/audio/queue.js +++ b/front/src/audio/queue.js @@ -86,6 +86,8 @@ class Queue { cache.remove('queue') } setVolume (newValue) { + newValue = Math.min(newValue, 1) + newValue = Math.max(newValue, 0) this.state.volume = newValue if (this.audio.setVolume) { this.audio.setVolume(newValue) @@ -94,7 +96,9 @@ class Queue { } cache.set('volume', newValue) } - + incrementVolume (value) { + this.setVolume(this.state.volume + value) + } reorder (oldIndex, newIndex) { // called when the user uses drag / drop to reorder // tracks in queue diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index e39dd16b9cc3eee8c0528a313011e317304aa0b0..0ce16a75f94a6b597a2ea0e3d120c336533232c7 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -87,10 +87,15 @@ <div class="ui inverted segment player-wrapper"> <player></player> </div> + <GlobalEvents + @keydown.r.stop="queue.restore" + /> </div> </template> <script> +import GlobalEvents from 'vue-global-events' + import Player from '@/components/audio/Player' import favoriteTracks from '@/favorites/tracks' import Logo from '@/components/Logo' @@ -109,7 +114,8 @@ export default { Player, SearchBar, Logo, - draggable + draggable, + GlobalEvents }, data () { return { diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue index b72f37c5c83ff741ba336d2be1d51dca595845eb..92ea9d0a48297ac1be4f65a894c584fd801e6282 100644 --- a/front/src/components/audio/Player.vue +++ b/front/src/components/audio/Player.vue @@ -56,10 +56,20 @@ <i title="Clear your queue" @click="queue.clean()" :class="['ui', 'trash', 'secondary', {'disabled': queue.tracks.length === 0}, 'icon']" :disabled="queue.tracks.length === 0"></i> </div> </div> + <GlobalEvents + @keydown.space.prevent="pauseOrPlay" + @keydown.ctrl.left.prevent="queue.previous" + @keydown.ctrl.right.prevent="queue.next" + @keydown.ctrl.down.prevent="queue.incrementVolume(-0.1)" + @keydown.ctrl.up.prevent="queue.incrementVolume(0.1)" + /> + </div> </template> <script> +import GlobalEvents from 'vue-global-events' + import queue from '@/audio/queue' import Track from '@/audio/track' import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon' @@ -68,7 +78,8 @@ import radios from '@/radios' export default { name: 'player', components: { - TrackFavoriteIcon + TrackFavoriteIcon, + GlobalEvents }, data () { return {