Skip to content

Commit

Permalink
Merge pull request #66 from casualsnek/development
Browse files Browse the repository at this point in the history
Merge Development
  • Loading branch information
casualsnek authored May 27, 2023
2 parents 58bb188 + ac87cbe commit 8b9badd
Show file tree
Hide file tree
Showing 42 changed files with 2,020 additions and 1,164 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ lib64/
parts/
sdist/
var/
release/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
PKGBUILD/*.xz
PKGBUILD/*.zip
PKGBUILD/pkg/
PKGBUILD/src/
PKGBUILD/.SRCINFO

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -105,6 +111,7 @@ celerybeat.pid
# Environments
.env
.venv
.idea
env/
venv*/
ENV/
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/onthespot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions PKGBUILD/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pkgname=onthespot-git
pkgver=0.5
_branch="main"
pkgrel=1
pkgdesc="Qt based music downloader written in python"
arch=('any')
url="https://github.com/casualsnek/onthespot"
license=('GPLv2')
depends=('ffmpeg' 'python-requests' 'python-pyqt5' 'python-pillow' 'python-show-in-file-manager' 'python-certifi' 'python-pyxdg' 'python-librespot' 'python-music-tag')
conflicts=('onthespot')
provides=('onthespot')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
optdepends=()
source=("https://github.com/casualsnek/onthespot/archive/refs/heads/$_branch.zip")
sha256sums=(SKIP)

build() {
cd "onthespot-$_branch"
python -m build --wheel --no-isolation
}

pkgver() {
grep "self.version = *" "$PWD/onthespot-$_branch/src/onthespot/otsconfig.py" | sed 's/self.version = //g;s/ //g'
}

package() {
cd "onthespot-$_branch"
python -m installer --destdir="$pkgdir" dist/*.whl
install -dm 755 "$pkgdir/usr/share/applications"
install -dm 755 "$pkgdir/usr/share/icons/hicolor/"{256x256,scalable}"/apps/"
install -Dm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
install -Dm 644 "src/onthespot/resources/org.eu.casualsnek.onthespot.desktop" "$pkgdir/usr/share/applications/"
install -Dm 644 "src/onthespot/resources/icon.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/casual_onthespot.svg"
install -Dm 644 "src/onthespot/resources/icon.png" "$pkgdir/usr/share/icons/hicolor/256x256/apps/casual_onthespot.png"
}
85 changes: 57 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
![Logo](src/onthespot/resources/icon.png)

# Onthespot

qt based music downloader written in python.

![Screenshot](https://i.imgur.com/C4V94gy.png)

### Discord for discussions: [Discord Invite](https://discord.gg/hz4mAwSujH)
If you have an idea for an improvement or feature, create a issue or join the discord server to discuss!

# 1. Installing/launching application:
## 1.1. From source
## 1.1. Launch without installing - from source
Make sure [python3](https://www.python.org/downloads) and [Git](https://git-scm.com/downloads) are installed on your system, if you are on windows you also need to install Microsoft C++ build tools from [HERE](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and restart your computer before starting build process.
- Download or Clone the repo ```git clone https://github.com/casualsnek/onthespot```
- Navigate to the onthespot directory ```cd onthespot```
- Install the dependencies with ```pip install -r requirements.txt```
- Launch the application with ```python3 __init__.py```
- Navigate to source directory ```cd src```
- Launch the application with ```python3 -m onthespot```

*Windows users should also follow these extra steps before running:* ```python3 onthespot.py```
```
pip install winsdk
```

## 1.2. Using prebuilt binaries
## 1.2. Using portable prebuilt binaries
### On Linux
#### Arch Linux
`onthespot` is available for arch linux and arch linux based distributions in arch user repository (aur) as [onthespot-git](https://aur.archlinux.org/packages/onthespot-git).
Expand All @@ -37,24 +42,25 @@ Download Latest 'onthespot_linux' from the release section and execute with
./onethespot_linux
```
### On Windows
Download Latest 'onthespot_win_ffm.exe' or 'onthespot_win.exe' from the Release section and execute by double clicking the downloaded file.
Download Latest 'onthespot_win_ffm.exe' or 'onthespot_win.exe' from the Release section and execute by double-clicking the downloaded file.

The binaries with filename ending with '_ffm' have ffmpeg bundled and should not require manual installation.

If you are using binaries that does not bundle ffmpeg and downloads gets stuck at 99% with ```Converting``` on progress text, you are missing ffmpeg ! Please install it by following the instructions below

#### Installing ffmpeg in windows
- Open Windows Explorer and Navigate to ```C:\``` Drive and make a folder name ```ffmpeg``` there
- Download ffmpef zip from [https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z](https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z) then copy the ``bin`` folder from zip to ```C:\ffmpeg```
- Download ffmpeg zip from [https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z](https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z) then copy the ``bin`` folder from zip to ```C:\ffmpeg```
- Open CMD as administrator and run the command: ```setx /m PATH "C:\ffmpeg\bin;%PATH%"```

Now the application should work as expected.


# 2. Building manually
Building on any OS requires Git, Python3 and Pip installed. Make sure you have them installed !
# 2. Building/packaging manually
Building or packaging on any OS requires Git, Python3 and Pip installed. Make sure you have them installed !

## 2.1. On Linux/nix
## 2.1. Building portable binaries
### 2.1.1 On Linux/nix
Open terminal emulator and run the following command to clone the repository and build.
```bash
git clone https://github.com/casualsnek/onthespot
Expand All @@ -67,8 +73,7 @@ bash ./build_linux.sh
```
After the command completes, you should have a 'dist' directory in repository root containing built 'onthespot_linux' binary.

## 2.2. On Windows
Download Microsoft C++ build tools from [Here](https://visualstudio.microsoft.com/visual-cpp-build-tools/). Setup/Install it and reboot your computer. ( Required for building simpleaudio python module)
### 2.1.2. On Windows

Open cmd and run the following command to clone the repository and build.
```cmd
Expand All @@ -84,20 +89,36 @@ build_winC2.bat
```
After the command completes, you should have a 'dist' directory in repository root containing built 'onthespot_win.exe' binary.

## 2.2. Building wheel for installing with pip
You can also build onthespot as wheel and install it as python module via pip in your system. It provides better integration with system, like using your system's Qt style and themes as well as you can use provided icon and .desktop file for better integration under linux systems.

Make sure you have set up tools installed !

Open terminal emulator and run the following command to clone the repository and build.
```bash
git clone https://github.com/casualsnek/onthespot
cd onthespot
python -m build
```
This will create a dist directory containing .whl file that can now be installed with pip, the application can be launched with the command ```onthespot_gui``` or ```python3 -m onthespot``` after installing !

**NOTE :** If you are packaging onthespot for distribution, copy ```src/onthespot/resources/icon.svg``` to either ```/usr/share/icons/hicolor/scalable/apps/casual_onthespot.svg``` or ```$HOME/.local/share/icons/hicolor/scalable/apps/casual_onthespot.svg```, and ``` src/onthespot/resources/org.eu.casualsnek.onthespot.desktop``` to either ```/usr/share/applications/org.eu.casualsnek.onthespot.desktop``` or ```$HOME/.local/share/applications/org.eu.casualsnek.onthespot.desktop```. This allows application to be better integrated to desktop environments !

If you have ideas for improvement/features create a issue or join discord server for discussion !
<br>
If you have ideas for improvement/features create an issue or join discord server for discussion !

# 3. Basic Usage
## Getting started
On your first launch of application you will get a warning that no spotify accounts are added, click ok and add your account(s) at the bottom of the application. After adding your accounts, close and restart the application. Having multiple accounts will let you download multiple songs at a time.

## Searching/Downloading via query
Click on 'Search' tab then enter your query and cick search to search for songs/artists/albums/playlists and click download.
Click on 'Search' tab then enter your query and click search to search for songs/artists/albums/playlists and click download.
You can download any media like 'Albums', 'Tracks', etc., that appear on the results table all at once by using the download buttons below the results table.
*Note that Media Type other than 'Tracks' can take a little longer to parse and download. The application may appear to be frozen in this state !*

## Downloading by URL
Enter the url in the url field then click download.
Enter the url in the search field then click download.
You can also enter path of text file containing URL, and it will queue all url(s) in it !
*Note that Media Type other than 'Tracks' can take a little longer to parse and download. Application may appear to be frozen in this state !*

## Download status
Expand All @@ -123,12 +144,20 @@ Default track names are ```AlbumFormatter/TrackName```
- **Track name formatter**:
This option allows you to set the naming scheme of downloaded tracks.
Variables can be used by enclosing them between `{}`. A few variables are available to use in the naming scheme:
- artist : name of artist of track
- album : name of album the track is in *
- name : name of track
- rel_year : release year of track
- disc_number : disk number in which track lies *
- track_number : serial Number of track in album *
- artist : Name of artist of track
- album : Name of album the track is in *
- name : Name of track
- rel_year : Release year of track
- disc_number : Disk number in which track lies *
- track_number : Serial Number of track in album *
- playlist_name : Name of playlist if the track is being downloaded as part of playlist *
- playlist_owner : Name of playlist if the track is being downloaded as part of playlist *
- playlist_desc : Description of playlist if the track is being downloaded as part of playlist *
- genre : Genre of song *
- label : Name of record label
- explicit : 'Explicit' if the song is marked explicit else it will be blank
- trackcount : Total number of tracks on the album this track is in
- disccount : Total number of discs on the album this track is in
- spotid : Spotify ID
- Example: ```Song: {name} of album: {album} Released in {rel_year}```.
The value of variables with their description ending in * maybe empty in some cases. This can also be a path.
Expand All @@ -139,8 +168,13 @@ Variables can be used by enclosing them between `{}`. A few variables are availa
- artist : name of the main artist of the album
- rel_year: the release year of the album *
- album: name of the album
- playlist_name : Name of playlist if the track is being downloaded as part of playlist *
- playlist_owner : Name of playlist if the track is being downloaded as part of playlist *
- playlist_desc : Description of playlist if the track is being downloaded as part of playlist *
- genre : Genre of song *
- label : Name of record label
- Example: ```{artist}/{rel_year}/{album}```.
The value of variables with their description ending in * maybe empty in some cases. This can be a path too.
The value of variables with their description ending in * maybe empty in some cases. This can be a path too.

- **Download chunk size**:
Size of chunks (bytes) used for downloading.
Expand All @@ -153,25 +187,20 @@ Time to wait before attempting another download after failed attempt.

- **Skip bytes at the end (download end skip bytes)**:
Sometimes the last few bytes of a track can't be downloaded which causes 'PD Error' to show up which causes downloads to fail constantly, this sets the number of bytes to skip downloading if this happens.
The value might change but the current working vaue is '167' bytes. If you get 'decode errors' or incomplete song downloads try setting it to 0.
The value might change but the current working value is '167' bytes. If you get 'decode errors' or incomplete song downloads try setting it to 0.

- **Force Artist/Album dir for track/playlist items**:
If this is disabled the tracks downloaded will be placed in the root of download directory instead of artist/album directories.
Enabling this might cause slower download parsing but makes orgainsing music easier.
Enabling this might cause slower download parsing but makes organising music easier.

- **Media Format**:
Format of media you want your final music download to be in.
Do not include '.' in it. This setting will be ignored while using the raw media download option.

# 5. Issues
Decode error: If you are receiving this error, your account might have got restricted. Wait some time or try a different account. The application may crash frequently as there is no proper exception handling yet. You can help by opening a new issue with the error message displayed in your console window after the application misbehaves.

# 6. TODOS
- ~~Synced lyrics downloads~~
- Improve UI/UX ( Suggestions needed by users )
- Refactor code

# 7. Contributing/Supporting
# 6. Contributing/Supporting
You can write code to include additional feature or bug fixes or make a issue regarding bugs and features or just spread the work about the application :)
If you want to support financially, you can visit [Here](https://github.com/casualsnek/casualsnek) and support through open collective or BTC
If you like the project, show your support by giving it a star :) !
14 changes: 0 additions & 14 deletions __init__.py

This file was deleted.

59 changes: 38 additions & 21 deletions build_linux.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,57 @@
#!/bin/bash

clean_build_dirs () {
[ -d ./__pycache__ ] && rm -rf __pycache__
[ -d ./build ] && rm -rf ./build
[ -d ./venv ] && rm -rf ./venv
[ -f ./onthespot_linux.spec ] && rm ./onthespot_linux.spec
[ -f ./onthespot_linux_ffm.spec ] && rm ./onthespot_linux_ffm.spec
}


echo "========= OnTheSpot Linux Build Script ==========="
echo " => Cleaning up !"
rm -rf __pycache__
if [ -f "./dist/onthespot_linux" ]; then
rm ./dist/onthespot_linux
fi
rm -rf ./build
rm -rf ./venv
[ -f ./dist/onthespot_linux ] && rm ./dist/onthespot_linux
[ -f ./dist/onthespot_linux_ffm ] && rm ./dist/onthespot_linux_ffm
clean_build_dirs

echo " => Creating virtual env."
python3 -m venv venv

echo " => Switching to virtual env."
source ./venv/bin/activate

echo " => Installing 'pyinstaller' via pip..."
pip install pyinstaller
echo " => Installing dependencies pip..."

echo " => Installing dependencies to venv with pip..."
pip install -r requirements.txt

if [ -f "ffbin_nix/ffmpeg" ]; then
echo " => Found 'ffbin_win' directory and ffmpeg binary.. Using ffmpeg binary append mode "
pyinstaller --onefile \
--add-data="gui/qtui/*.ui:qui/qtui" \
--add-binary="ffbin_nix/*:bin/ffmpeg" \
--paths="." \
--name="onthespot_linux" \
__init__.py
--add-data="src/onthespot/gui/qtui/*.ui:onthespot/gui/qtui" \
--add-data="src/onthespot/resources/*.png:onthespot/resources" \
--add-binary="ffbin_nix/*:onthespot/bin/ffmpeg" \
--paths="src/onthespot" \
--name="onthespot_linux_ffm" \
--icon="src/onthespot/resources/icon.png" \
src/portable.py
else
echo " => Building to use ffmpeg binary from system... "
pyinstaller --onefile \
--add-data="gui/qtui/*.ui:gui/qtui" \
--paths="." \
--add-data="src/onthespot/gui/qtui/*.ui:onthespot/gui/qtui" \
--add-data="src/onthespot/resources/*.png:onthespot/resources" \
--paths="src/onthespot" \
--name="onthespot_linux" \
__init__.py
--icon="src/onthespot/resources/icon.png" \
src/portable.py
fi
echo " => Setting permissions.. "
chmod +x ./dist/onthespot_linux
echo " => Cleaning.. "
rm onthespot_linux.spec
rm -rf ./build
rm -rf __pycache__
echo " => Setting executable permissions.. "
[ -f ./dist/onthespot_linux ] && chmod +x ./dist/onthespot_linux &>./build_nix.log
[ -f ./dist/onthespot_linux_ffm ] && chmod +x ./dist/onthespot_linux_ffm &>./build_nix.log

echo " => Cleaning .. "
clean_build_dirs

echo " => Done "
18 changes: 14 additions & 4 deletions build_winC1.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
@echo off
echo ========= OnTheSpot Windows Build Script ===========
echo =^> Cleaning up !"
rmdir build /s /q
rmdir __pycache__ /s /q
rmdir venvwin /s /q
echo =^> Cleaning up !
if exist build\ (
rmdir build /s /q
)
if exist __pycache__\ (
rmdir __pycache__ /s /q
)
if exist venvwin\ (
rmdir venvwin /s /q
)

if exist dist\onthespot_win.exe (
del /F /Q /A dist\onthespot_win.exe
)
if exist dist\onthespot_win_ffm.exe (
del /F /Q /A dist\onthespot_win_ffm.exe
)
echo =^> Creating virtual env.
python.exe -m venv venvwin
echo =^> Switching to virtual env.
Expand Down
Loading

0 comments on commit 8b9badd

Please sign in to comment.