From 44760aab6f8fcf8ee2b564587cc2ec0c7ab535f1 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Fri, 14 Jan 2022 16:58:53 +0600 Subject: [PATCH] Unsafe List.last accessor bugfix (#issues/2) PKGBUILD recreated & adjusted License created flatpak config created (dummy) --- LICENSE | 12 ++++++++++++ aur-struct/.SRCINFO | 14 ++++++-------- aur-struct/PKGBUILD | 17 +++++++++-------- lib/components/Home.dart | 15 +++++++++------ lib/components/Player.dart | 5 ++++- lib/components/PlaylistView.dart | 6 ++++-- oss.krtirtho.Spotube.yml | 13 +++++++++++++ 7 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 LICENSE create mode 100644 oss.krtirtho.Spotube.yml diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..20e05c25 --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +BSD 4-Clause License + +Copyright (c) 2022 Kingkor Roy Tirtho. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software must display the following acknowledgement: +This product includes software developed by Kingkor Roy Tirtho. +4. Neither the name of the Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY KINGKOR ROY TIRTHO AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KINGKOR ROY TIRTHO AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/aur-struct/.SRCINFO b/aur-struct/.SRCINFO index a7e6e251..e592d01f 100644 --- a/aur-struct/.SRCINFO +++ b/aur-struct/.SRCINFO @@ -1,13 +1,11 @@ -pkgbase = spotube-bin - pkgdesc = A music streaming app combining the power of Spotify & Youtube - pkgver = 0.0.3 +pkgbase = spotube + pkgdesc = A lightweight free Spotify desktop-client which handles playback manually, streams music using Youtube & no Spotify premium account is needed + pkgver = 1.0.0 pkgrel = 1 url = https://github.com/KRTirtho/spotube/ arch = x86_64 - license = MIT - depends = mpv - depends = youtube-dl - source = https://github.com/KRTirtho/spotube//releases/download/v0.0.3/Spotube_linux-x86_64-v0.0.3.zip + license = BSD 4-Clause + source = https://github.com/KRTirtho/spotube/releases/download/v1.0.0/Spotube-linux-x86_64.tar.xz -pkgname = spotube-bin +pkgname = spotube diff --git a/aur-struct/PKGBUILD b/aur-struct/PKGBUILD index 4d207f1d..b9b7b92f 100644 --- a/aur-struct/PKGBUILD +++ b/aur-struct/PKGBUILD @@ -1,14 +1,14 @@ -# Maintainer: KRTirtho +# Maintainer: Kingkor Roy Tirtho pkgname=spotube pkgver=1.0.0 pkgrel=1 epoch= -pkgdesc="A music streaming app combining the power of Spotify & Youtube" +pkgdesc="A lightweight free Spotify desktop-client which handles playback manually, streams music using Youtube & no Spotify premium account is needed" arch=(x86_64) url="https://github.com/KRTirtho/spotube/" -license=('MIT') +license=('BSD 4-Clause') groups=() -depends=('mpv' 'yt-dlp') +depends=() makedepends=() checkdepends=() optdepends=() @@ -19,17 +19,18 @@ backup=() options=() install= changelog= -source=("./spotube-v1.0.0-linux-x86-64.tar") +source=("https://github.com/KRTirtho/spotube/releases/download/v${version}/Spotube-linux-x86_64.tar.xz") noextract=() -md5sums=(a58727a9233d7d381872be59b622f864) +md5sums=(f1830c1edf38c236416bdd3bd33ec845) validpgpkeys=() package(){ install -dm755 "${pkgdir}/usr/share/icons/${pkgname}" + install -dm755 "${pkgdir}/usr/share/applications" install -dm755 "${pkgdir}/usr/share/${pkgname}" install -dm755 "${pkgdir}/usr/bin" cp -ra ./ "${pkgdir}/usr/share/${pkgname}" - cp ./spotube.desktop ~/.local/share/applications - cp ./data/flutter_assets/assets/spotube-logo.png "${pkgdir}/usr/share/icons/${pkgname}" + cp ./spotube.desktop "${pkgdir}/usr/share/applications" + cp ./spotube-logo.png "${pkgdir}/usr/share/icons/${pkgname}" ln -s "/usr/share/${pkgname}/spotube" "${pkgdir}/usr/bin/${pkgname}" } diff --git a/lib/components/Home.dart b/lib/components/Home.dart index 79890dce..43090883 100644 --- a/lib/components/Home.dart +++ b/lib/components/Home.dart @@ -185,7 +185,11 @@ class _HomeState extends State { return FutureBuilder( future: data.spotifyApi.me.get(), builder: (context, snapshot) { - var avatarImg = snapshot.data?.images?.last.url; + var avatarImg = ((snapshot.data?.images?.isNotEmpty ?? + false) && + snapshot.data?.images?.last.url != null) + ? snapshot.data!.images!.last.url! + : "https://avatars.dicebear.com/api/human/${snapshot.data?.id}.png"; return Padding( padding: const EdgeInsets.all(16), child: Row( @@ -193,11 +197,10 @@ class _HomeState extends State { children: [ Row( children: [ - if (avatarImg != null) - CircleAvatar( - backgroundImage: - CachedNetworkImageProvider(avatarImg), - ), + CircleAvatar( + backgroundImage: + CachedNetworkImageProvider(avatarImg), + ), const SizedBox(width: 10), Text( snapshot.data?.displayName ?? "User's name", diff --git a/lib/components/Player.dart b/lib/components/Player.dart index 821c603b..783214f0 100644 --- a/lib/components/Player.dart +++ b/lib/components/Player.dart @@ -227,7 +227,10 @@ class _PlayerState extends State with WidgetsBindingObserver { _playTrack(playback.currentTrack!, playback); } - String? albumArt = playback.currentTrack?.album?.images?.last.url; + String? albumArt = + (playback.currentTrack?.album?.images?.isNotEmpty ?? false) + ? playback.currentTrack?.album?.images?.last.url + : null; return Material( type: MaterialType.transparency, diff --git a/lib/components/PlaylistView.dart b/lib/components/PlaylistView.dart index 95d67b55..47d32844 100644 --- a/lib/components/PlaylistView.dart +++ b/lib/components/PlaylistView.dart @@ -17,8 +17,10 @@ class PlaylistView extends StatefulWidget { class _PlaylistViewState extends State { List trackToTableRow(List tracks) { return tracks.asMap().entries.map((track) { - var thumbnailUrl = track.value.album?.images?.last.url; - var duration = + String? thumbnailUrl = (track.value.album?.images?.isNotEmpty ?? false) + ? track.value.album?.images?.last.url + : null; + String duration = "${track.value.duration?.inMinutes.remainder(60)}:${zeroPadNumStr(track.value.duration?.inSeconds.remainder(60) ?? 0)}"; return (TableRow( children: [ diff --git a/oss.krtirtho.Spotube.yml b/oss.krtirtho.Spotube.yml new file mode 100644 index 00000000..ce6957c6 --- /dev/null +++ b/oss.krtirtho.Spotube.yml @@ -0,0 +1,13 @@ +app-id: oss.krtirtho.Spotube +runtime: org.freedesktop.Platform +runtime-version: '21.08' +sdk: org.freedesktop.Sdk +command: spotube +modules: + - name: spotube + buildsystem: simple + build-commands: + - install -D hello.sh /app/bin/hello.sh + sources: + - type: file + path: hello.sh \ No newline at end of file