🌟 Re-add all project files.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
max_line_length = 120
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{py, pyi}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = space
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{diff,patch}]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.json]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
@@ -0,0 +1,13 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: exislow
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
custom: ["https://www.buymeacoffee.com/exislow"]
|
||||
@@ -0,0 +1,33 @@
|
||||
name: "setup-poetry-env"
|
||||
description: "Composite action to setup the Python and poetry environment."
|
||||
|
||||
inputs:
|
||||
python-version:
|
||||
required: false
|
||||
description: "The python version to use"
|
||||
default: "3.11"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Set up python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ inputs.python-version }}
|
||||
|
||||
- name: Install Poetry
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
virtualenvs-in-project: true
|
||||
|
||||
- name: Load cached venv
|
||||
id: cached-poetry-dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .venv
|
||||
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
run: poetry install --no-interaction
|
||||
shell: bash
|
||||
@@ -0,0 +1,70 @@
|
||||
name: master
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
|
||||
- name: Set up the environment
|
||||
uses: ./.github/actions/setup-poetry-env
|
||||
|
||||
- name: Run checks
|
||||
run: make check
|
||||
|
||||
tox:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11", "3.12"]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install Poetry
|
||||
uses: snok/install-poetry@v1
|
||||
|
||||
- name: Load cached venv
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .tox
|
||||
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
|
||||
|
||||
- name: Install tox
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install tox tox-gh-actions
|
||||
|
||||
- name: Test with tox
|
||||
run: tox
|
||||
|
||||
check-docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up the environment
|
||||
uses: ./.github/actions/setup-poetry-env
|
||||
|
||||
- name: Check if documentation can be built
|
||||
run: poetry run mkdocs build -s
|
||||
@@ -0,0 +1,56 @@
|
||||
name: release-master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
# release:
|
||||
# types: [published]
|
||||
# branches: [master]
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up the environment
|
||||
uses: ./.github/actions/setup-poetry-env
|
||||
|
||||
- name: Export tag
|
||||
id: vars
|
||||
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and publish
|
||||
run: |
|
||||
source .venv/bin/activate
|
||||
poetry version $RELEASE_VERSION
|
||||
make build-and-publish
|
||||
env:
|
||||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
||||
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
|
||||
|
||||
- name: GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
deploy-docs:
|
||||
needs: publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up the environment
|
||||
uses: ./.github/actions/setup-poetry-env
|
||||
|
||||
- name: Deploy documentation
|
||||
run: poetry run mkdocs gh-deploy --force
|
||||
# TODO: Build Qt GUI Standalone.
|
||||
@@ -0,0 +1,56 @@
|
||||
default_language_version:
|
||||
python: python3.11
|
||||
|
||||
default_stages: [commit, push]
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: "v4.4.0"
|
||||
hooks:
|
||||
- id: check-case-conflict
|
||||
- id: check-merge-conflict
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
|
||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||
rev: "v0.0.230"
|
||||
hooks:
|
||||
- id: ruff
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: "v3.0.3"
|
||||
hooks:
|
||||
- id: prettier
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: check-yaml
|
||||
- id: end-of-file-fixer
|
||||
exclude: LICENSE
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
name: pyupgrade
|
||||
entry: poetry run pyupgrade --py310-plus
|
||||
types: [python]
|
||||
language: system
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: isort
|
||||
name: isort
|
||||
entry: poetry run isort --settings-path pyproject.toml
|
||||
types: [python]
|
||||
language: system
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: black
|
||||
name: black
|
||||
entry: poetry run black --config pyproject.toml
|
||||
types: [python]
|
||||
language: system
|
||||
@@ -0,0 +1,30 @@
|
||||
# v0.4.9
|
||||
|
||||
- Fixed: Exception on missing file read (config, token) instead of creation.
|
||||
|
||||
# v0.4.8
|
||||
|
||||
- Fixed: GUI dependencies are treated as extra now (pip).
|
||||
|
||||
# v0.4.7
|
||||
|
||||
- Fixed: GUI dependencies are treated as extra now (pip).
|
||||
|
||||
# v0.4.6
|
||||
|
||||
- GUI dependencies are treated as extra now (pip).
|
||||
|
||||
# v0.4.5
|
||||
|
||||
- Fixed "Mix" download.
|
||||
- Fixed relative imports.
|
||||
- Fixed PyPi build.
|
||||
- Fixed crash on lyrics error.
|
||||
|
||||
# v0.4.2
|
||||
|
||||
- Added more basic features.
|
||||
|
||||
# v0.4.1
|
||||
|
||||
- Initial featured running version.
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
# Contributing to `tidal-dl-ng`
|
||||
|
||||
Contributions are welcome, and they are greatly appreciated!
|
||||
Every little bit helps, and credit will always be given.
|
||||
|
||||
You can contribute in many ways:
|
||||
|
||||
# Types of Contributions
|
||||
|
||||
## Report Bugs
|
||||
|
||||
Report bugs at https://github.com/exislow/tidal-dl-ng/issues
|
||||
|
||||
If you are reporting a bug, please include:
|
||||
|
||||
- Your operating system name and version.
|
||||
- Any details about your local setup that might be helpful in troubleshooting.
|
||||
- Detailed steps to reproduce the bug.
|
||||
|
||||
## Fix Bugs
|
||||
|
||||
Look through the GitHub issues for bugs.
|
||||
Anything tagged with "bug" and "help wanted" is open to whoever wants to implement a fix for it.
|
||||
|
||||
## Implement Features
|
||||
|
||||
Look through the GitHub issues for features.
|
||||
Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.
|
||||
|
||||
## Write Documentation
|
||||
|
||||
Cookiecutter PyPackage could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.
|
||||
|
||||
## Submit Feedback
|
||||
|
||||
The best way to send feedback is to file an issue at https://github.com/exislow/tidal-dl-ng/issues.
|
||||
|
||||
If you are proposing a new feature:
|
||||
|
||||
- Explain in detail how it would work.
|
||||
- Keep the scope as narrow as possible, to make it easier to implement.
|
||||
- Remember that this is a volunteer-driven project, and that contributions
|
||||
are welcome :)
|
||||
|
||||
# Get Started!
|
||||
|
||||
Ready to contribute? Here's how to set up `tidal-dl-ng` for local development.
|
||||
Please note this documentation assumes you already have `poetry` and `Git` installed and ready to go.
|
||||
|
||||
1. Fork the `tidal-dl-ng` repo on GitHub.
|
||||
|
||||
2. Clone your fork locally:
|
||||
|
||||
```bash
|
||||
cd <directory_in_which_repo_should_be_created>
|
||||
git clone git@github.com:YOUR_NAME/tidal-dl-ng.git
|
||||
```
|
||||
|
||||
3. Now we need to install the environment. Navigate into the directory
|
||||
|
||||
```bash
|
||||
cd tidal-dl-ng
|
||||
```
|
||||
|
||||
If you are using `pyenv`, select a version to use locally. (See installed versions with `pyenv versions`)
|
||||
|
||||
```bash
|
||||
pyenv local <x.y.z>
|
||||
```
|
||||
|
||||
Then, install and activate the environment with:
|
||||
|
||||
```bash
|
||||
poetry install
|
||||
poetry shell
|
||||
```
|
||||
|
||||
4. Install pre-commit to run linters/formatters at commit time:
|
||||
|
||||
```bash
|
||||
poetry run pre-commit install
|
||||
```
|
||||
|
||||
5. Create a branch for local development:
|
||||
|
||||
```bash
|
||||
git checkout -b name-of-your-bugfix-or-feature
|
||||
```
|
||||
|
||||
Now you can make your changes locally.
|
||||
|
||||
6. Don't forget to add test cases for your added functionality to the `tests` directory.
|
||||
|
||||
7. When you're done making changes, check that your changes pass the formatting tests.
|
||||
|
||||
```bash
|
||||
make check
|
||||
```
|
||||
|
||||
Now, validate that all unit tests are passing:
|
||||
|
||||
```bash
|
||||
make test
|
||||
```
|
||||
|
||||
9. Before raising a pull request you should also run tox.
|
||||
This will run the tests across different versions of Python:
|
||||
|
||||
```bash
|
||||
tox
|
||||
```
|
||||
|
||||
This requires you to have multiple versions of python installed.
|
||||
This step is also triggered in the CI/CD pipeline, so you could also choose to skip this step locally.
|
||||
|
||||
10. Commit your changes and push your branch to GitHub:
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Your detailed description of your changes."
|
||||
git push origin name-of-your-bugfix-or-feature
|
||||
```
|
||||
|
||||
11. Submit a pull request through the GitHub website.
|
||||
|
||||
# Pull Request Guidelines
|
||||
|
||||
Before you submit a pull request, check that it meets these guidelines:
|
||||
|
||||
1. The pull request should include tests.
|
||||
|
||||
2. If the pull request adds functionality, the docs should be updated.
|
||||
Put your new functionality into a function with a docstring, and add the feature to the list in `README.md`.
|
||||
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -0,0 +1,66 @@
|
||||
.PHONY: install
|
||||
install: ## Install the poetry environment and install the pre-commit hooks
|
||||
@echo "🚀 Creating virtual environment using pyenv and poetry"
|
||||
@poetry install
|
||||
@poetry run pre-commit install
|
||||
@poetry shell
|
||||
|
||||
.PHONY: check
|
||||
check: ## Run code quality tools.
|
||||
@echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
|
||||
@poetry check --lock
|
||||
@echo "🚀 Linting code: Running pre-commit"
|
||||
@poetry run pre-commit run -a
|
||||
@echo "🚀 Static type checking: Running mypy"
|
||||
@poetry run mypy
|
||||
@echo "🚀 Checking for obsolete dependencies: Running deptry"
|
||||
@poetry run deptry .
|
||||
|
||||
.PHONY: test
|
||||
test: ## Test the code with pytest
|
||||
@echo "🚀 Testing code: Running pytest"
|
||||
@poetry run pytest --doctest-modules
|
||||
|
||||
.PHONY: build
|
||||
build: clean-build ## Build wheel file using poetry
|
||||
@echo "🚀 Creating wheel file"
|
||||
@poetry build
|
||||
|
||||
.PHONY: clean-build
|
||||
clean-build: ## clean build artifacts
|
||||
@rm -rf dist
|
||||
|
||||
.PHONY: publish
|
||||
publish: ## publish a release to pypi.
|
||||
@echo "🚀 Publishing: Dry run."
|
||||
@poetry config pypi-token.pypi $(PYPI_TOKEN)
|
||||
@poetry publish --dry-run
|
||||
@echo "🚀 Publishing."
|
||||
@poetry publish
|
||||
|
||||
.PHONY: build-and-publish
|
||||
build-and-publish: build publish ## Build and publish.
|
||||
|
||||
.PHONY: docs-test
|
||||
docs-test: ## Test if documentation can be built without warnings or errors
|
||||
@poetry run mkdocs build -s
|
||||
|
||||
.PHONY: docs
|
||||
docs: ## Build and serve the documentation
|
||||
@poetry run mkdocs serve
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
# TODO: macos Signing: https://gist.github.com/txoof/0636835d3cc65245c6288b2374799c43
|
||||
.PHONY: gui
|
||||
gui: ## Build and serve the documentation
|
||||
@poetry run pyinstaller --noconfirm \
|
||||
--windowed --onefile \
|
||||
--name "TIDAL Downloader NG" \
|
||||
--noupx \
|
||||
--icon tidal_dl_ng/ui/icon.png \
|
||||
tidal_dl_ng/gui.py
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
@@ -0,0 +1,114 @@
|
||||
# 🔰 TIDAL Downloader Next Generation! (tidal-dl-ng)
|
||||
|
||||
[](https://img.shields.io/github/v/release/exislow/tidal-dl-ng)
|
||||
[](https://github.com/exislow/tidal-dl-ng/actions/workflows/main.yml?query=branch%3Amain)
|
||||
[](https://img.shields.io/github/commit-activity/m/exislow/tidal-dl-ng)
|
||||
[](https://img.shields.io/github/license/exislow/tidal-dl-ng)
|
||||
|
||||
This tool allows to download songs and videos from TIDAL (a paid plan is required!). You can use the command line or GUI
|
||||
version of this tool.
|
||||
|
||||
If you like this projects and want to support it, you can buy me a coffee :-)
|
||||
|
||||
<a href="https://www.buymeacoffee.com/exislow" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/arial-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
|
||||
<a href="https://ko-fi.com/exislow" target="_blank" rel="noopener noreferrer"><img src="https://help.ko-fi.com/hc/article_attachments/11833788361117" alt="61e11d430afb112ea33c3aa5_Button-1-p-500"></a>
|
||||
|
||||
## 💻 Installation / Upgrade
|
||||
|
||||
**Requirements**: Python 3.11 (other versions might work but are not tested!)
|
||||
|
||||
```bash
|
||||
pip install --upgrade tidal-dl-ng
|
||||
# AND if you like to have the GUI as well
|
||||
pip install --upgrade tidal-dl-ng[gui]
|
||||
```
|
||||
|
||||
You can use the command line (CLI) version to download media:
|
||||
|
||||
```bash
|
||||
tidal-dl-ng dl https://tidal.com/browse/track/46755209
|
||||
# OR
|
||||
tdn dl https://tidal.com/browse/track/46755209
|
||||
```
|
||||
|
||||
But also the GUI:
|
||||
|
||||
```bash
|
||||
tidal-dl-ng-gui
|
||||
# OR
|
||||
tdng
|
||||
# OR
|
||||
tidal-dl-ng gui
|
||||
```
|
||||
|
||||
## 🧁 Features
|
||||
|
||||
- Download Tracks, Videos, Albums, Playlists
|
||||
- Metadata for songs
|
||||
- Adjustable audio and video download quality.
|
||||
|
||||
## ▶️ Getting started with development
|
||||
|
||||
### 🚰 Install dependecies
|
||||
|
||||
Clone this repository and install the dependencies:
|
||||
|
||||
```bash
|
||||
poetry install --all-extras --with dev,docs
|
||||
```
|
||||
|
||||
The main entry points are:
|
||||
|
||||
```bash
|
||||
tidal_ng_dl/cli.py
|
||||
tidal_ng_dl/gui.py
|
||||
```
|
||||
|
||||
### 📺 GUI Builder
|
||||
|
||||
The GUI is build with `PySide6` using the [Qt Designer](https://doc.qt.io/qt-6/qtdesigner-manual.html):
|
||||
|
||||
```bash
|
||||
pyside6-designer
|
||||
```
|
||||
|
||||
After all changes are saved you need to translate the Qt Designer `*.ui` file into Python code:
|
||||
|
||||
```
|
||||
pyside6-uic tidal_dl_ng/ui/main.ui -o tidal_dl_ng/ui/main.py
|
||||
```
|
||||
|
||||
### 🏗 Build the project
|
||||
|
||||
To build the project use this command:
|
||||
|
||||
```bash
|
||||
make install
|
||||
```
|
||||
|
||||
The CI/CD pipeline will be triggered when you open a pull request, merge to main, or when you create a new release.
|
||||
|
||||
To finalize the set-up for publishing to PyPi or Artifactory, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/publishing/#set-up-for-pypi).
|
||||
For activating the automatic documentation with MkDocs, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/mkdocs/#enabling-the-documentation-on-github).
|
||||
To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/codecov/).
|
||||
|
||||
## ✨ Releasing a new version
|
||||
|
||||
- Create an API Token on [Pypi](https://pypi.org/).
|
||||
- Add the API Token to your projects secrets with the name `PYPI_TOKEN` by visiting [this page](https://github.com/exislow/tidal-dl-ng/settings/secrets/actions/new).
|
||||
- Create a [new release](https://github.com/exislow/tidal-dl-ng/releases/new) on Github.
|
||||
- Create a new tag in the form `*.*.*`.
|
||||
|
||||
For more details, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/cicd/#how-to-trigger-a-release).
|
||||
|
||||
## ‼️ Dislaimer
|
||||
|
||||
- For educational purposes only. I am not liable and responsible for any damage that happens.
|
||||
- You should not use this method to distribute or pirate music.
|
||||
- It may be illegal to use this app in your country.
|
||||
|
||||
## 🫂 Contributors
|
||||
|
||||
Thanks to all, who have contributed to this project!
|
||||
1
|
||||
<a href="https://github.com/exislow/tidal-dl-ng/graphs/contributors"><img src="https://contributors-img.web.app/image?repo=exislow/tidal-dl-ng" /></a>
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
site_name: tidal-dl-ng
|
||||
repo_url: https://github.com/exislow/tidal-dl-ng
|
||||
site_url: https://exislow.github.io/tidal-dl-ng
|
||||
site_description: TIDAL Medial Downloader Next Generation!
|
||||
site_author: Robert Honz
|
||||
edit_uri: edit/main/docs/
|
||||
repo_name: exislow/tidal-dl-ng
|
||||
copyright: Maintained by <a href="https://example.com">Robby</a>.
|
||||
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Modules: modules.md
|
||||
plugins:
|
||||
- search
|
||||
- mkdocstrings:
|
||||
handlers:
|
||||
python:
|
||||
setup_commands:
|
||||
- import sys
|
||||
- sys.path.append('../')
|
||||
theme:
|
||||
name: material
|
||||
feature:
|
||||
tabs: true
|
||||
palette:
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
primary: white
|
||||
accent: deep orange
|
||||
toggle:
|
||||
icon: material/brightness-7
|
||||
name: Switch to dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: black
|
||||
accent: deep orange
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Switch to light mode
|
||||
icon:
|
||||
repo: fontawesome/brands/github
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/exislow/tidal-dl-ng
|
||||
- icon: fontawesome/brands/python
|
||||
link: https://pypi.org/project/tidal-dl-ng
|
||||
|
||||
markdown_extensions:
|
||||
- toc:
|
||||
permalink: true
|
||||
- pymdownx.arithmatex:
|
||||
generic: true
|
||||
Generated
+2024
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
[virtualenvs]
|
||||
in-project = true
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
[project]
|
||||
name = "tidal-dl-ng"
|
||||
version = "0.4.11"
|
||||
description = "TIDAL Medial Downloader Next Generation!"
|
||||
authors = ["Robert Honz <cen.sored@gmail.com>"]
|
||||
repository = "https://github.com/exislow/tidal-dl-ng"
|
||||
documentation = "https://exislow.github.io/tidal-dl-ng/"
|
||||
readme = "README.md"
|
||||
packages = [
|
||||
{ include = "tidal_dl_ng" }
|
||||
]
|
||||
|
||||
[tool.poetry]
|
||||
name = "tidal-dl-ng"
|
||||
authors = ["Robert Honz <cen.sored@gmail.com>"]
|
||||
version = "0.4.11"
|
||||
description = "TIDAL Medial Downloader Next Generation!"
|
||||
repository = "https://github.com/exislow/tidal-dl-ng"
|
||||
documentation = "https://exislow.github.io/tidal-dl-ng/"
|
||||
readme = "README.md"
|
||||
packages = [
|
||||
{ include = "tidal_dl_ng" }
|
||||
]
|
||||
|
||||
[tool.poetry.scripts]
|
||||
tidal-dl-ng = "tidal_dl_ng.cli:app"
|
||||
tidal-dl-ng-gui = "tidal_dl_ng.gui:gui_activate"
|
||||
tdn = "tidal_dl_ng.cli:app"
|
||||
tdng = "tidal_dl_ng.gui:gui_activate"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.12"
|
||||
requests = "2.31.0"
|
||||
mutagen = "1.47.0"
|
||||
pycryptodome = "3.19.0"
|
||||
tidalapi = "0.7.3"
|
||||
dataclasses-json = "^0.6.3"
|
||||
pathvalidate = "^3.2.0"
|
||||
typer = {extras = ["all"], version = "^0.9.0"}
|
||||
m3u8 = "^4.0.0"
|
||||
ffmpeg-python = "^0.2.0"
|
||||
coloredlogs = "^15.0.1"
|
||||
pyside6 = {version = "^6.6.1", optional = true}
|
||||
pyqtdarktheme = {version = "^2.1.0", optional = true}
|
||||
|
||||
[tool.poetry.extras]
|
||||
gui = ["pyside6", "pyqtdarktheme"]
|
||||
|
||||
[tool.poetry.group.dev]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = "^7.4.3"
|
||||
deptry = "^0.12.0"
|
||||
mypy = "^1.7.1"
|
||||
pre-commit = "^3.5.0"
|
||||
tox = "^4.11.4"
|
||||
pyupgrade = "^3.15.0"
|
||||
bandit = "^1.7.5"
|
||||
black = "^23.11.0"
|
||||
darglint = "^1.8.1"
|
||||
isort = { extras = ["colors"], version = "^5.12.0" }
|
||||
mypy-extensions = "^1.0.0"
|
||||
pydocstyle = "^6.3.0"
|
||||
pylint = "^3.0.2"
|
||||
pyinstaller = "^6.3.0"
|
||||
pillow = "^10.1.0"
|
||||
|
||||
[tool.poetry.group.docs]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
mkdocs = "^1.5.3"
|
||||
mkdocs-material = "^9.4.14"
|
||||
mkdocstrings = { extras = ["python"], version = "^0.24.0" }
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py311"
|
||||
line-length = 120
|
||||
fix = true
|
||||
select = [
|
||||
# flake8-2020
|
||||
"YTT",
|
||||
# flake8-bandit
|
||||
"S",
|
||||
# flake8-bugbear
|
||||
"B",
|
||||
# flake8-builtins
|
||||
"A",
|
||||
# flake8-comprehensions
|
||||
"C4",
|
||||
# flake8-debugger
|
||||
"T10",
|
||||
# flake8-simplify
|
||||
"SIM",
|
||||
# isort
|
||||
"I",
|
||||
# mccabe
|
||||
"C90",
|
||||
# pycodestyle
|
||||
"E", "W",
|
||||
# pyflakes
|
||||
"F",
|
||||
# pygrep-hooks
|
||||
"PGH",
|
||||
# pyupgrade
|
||||
"UP",
|
||||
# ruff
|
||||
"RUF",
|
||||
# tryceratops
|
||||
"TRY",
|
||||
]
|
||||
ignore = [
|
||||
# LineTooLong
|
||||
"E501",
|
||||
# DoNotAssignLambda
|
||||
"E731",
|
||||
]
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
"tests/*" = ["S101"]
|
||||
|
||||
[tool.black]
|
||||
# https://github.com/psf/black
|
||||
target-version = ["py311"]
|
||||
line-length = 120
|
||||
color = true
|
||||
preview = true
|
||||
|
||||
exclude = '''
|
||||
/(
|
||||
\.git
|
||||
| \.hg
|
||||
| \.mypy_cache
|
||||
| \.tox
|
||||
| \.venv
|
||||
| _build
|
||||
| buck-out
|
||||
| build
|
||||
| dist
|
||||
| env
|
||||
| venv
|
||||
)/
|
||||
'''
|
||||
|
||||
[tool.isort]
|
||||
# https://github.com/timothycrosley/isort/
|
||||
py_version = 311
|
||||
line_length = 120
|
||||
known_typing = ["typing", "types", "typing_extensions", "mypy", "mypy_extensions"]
|
||||
sections = ["FUTURE", "TYPING", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
|
||||
include_trailing_comma = true
|
||||
profile = "black"
|
||||
multi_line_output = 3
|
||||
indent = 4
|
||||
color_output = true
|
||||
|
||||
[tool.mypy]
|
||||
# https://mypy.readthedocs.io/en/latest/config_file.html#using-a-pyproject-toml-file
|
||||
files = ["tidal_dl_ng"]
|
||||
python_version = "3.11"
|
||||
pretty = true
|
||||
show_traceback = true
|
||||
color_output = true
|
||||
allow_redefinition = false
|
||||
check_untyped_defs = true
|
||||
disallow_any_generics = true
|
||||
disallow_incomplete_defs = true
|
||||
ignore_missing_imports = true
|
||||
implicit_reexport = false
|
||||
no_implicit_optional = true
|
||||
show_column_numbers = true
|
||||
show_error_codes = true
|
||||
show_error_context = true
|
||||
strict_equality = true
|
||||
strict_optional = true
|
||||
warn_no_return = true
|
||||
warn_redundant_casts = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
warn_unused_configs = true
|
||||
warn_unused_ignores = true
|
||||
disallow_untyped_defs = "True"
|
||||
disallow_any_unimported = "True"
|
||||
@@ -0,0 +1,4 @@
|
||||
[darglint]
|
||||
# https://github.com/terrencepreilly/darglint
|
||||
strictness = long
|
||||
docstring_style = google
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
import importlib.metadata
|
||||
|
||||
try:
|
||||
# __package__ allows for the case where __name__ is "__main__"
|
||||
__version__ = importlib.metadata.version(__package__ or __name__)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
__version__ = "0.0.0"
|
||||
@@ -0,0 +1,102 @@
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
# TODO: Implement this into `Download`: Session should randomize the usage.
|
||||
__KEYS_JSON__ = """
|
||||
{
|
||||
"version": "1.0.1",
|
||||
"keys": [
|
||||
{
|
||||
"platform": "Fire TV",
|
||||
"formats": "Normal/High/HiFi(No Master)",
|
||||
"clientId": "OmDtrzFgyVVL6uW56OnFA2COiabqm",
|
||||
"clientSecret": "zxen1r3pO0hgtOC7j6twMo9UAqngGrmRiWpV7QC1zJ8=",
|
||||
"valid": "False",
|
||||
"from": "Fokka-Engineering (https://github.com/Fokka-Engineering/libopenTIDAL/blob/655528e26e4f3ee2c426c06ea5b8440cf27abc4a/README.md#example)"
|
||||
},
|
||||
{
|
||||
"platform": "Fire TV",
|
||||
"formats": "Master-Only(Else Error)",
|
||||
"clientId": "7m7Ap0JC9j1cOM3n",
|
||||
"clientSecret": "vRAdA108tlvkJpTsGZS8rGZ7xTlbJ0qaZ2K9saEzsgY=",
|
||||
"valid": "True",
|
||||
"from": "Dniel97 (https://github.com/Dniel97/RedSea/blob/4ba02b88cee33aeb735725cb854be6c66ff372d4/config/settings.example.py#L68)"
|
||||
},
|
||||
{
|
||||
"platform": "Android TV",
|
||||
"formats": "Normal/High/HiFi(No Master)",
|
||||
"clientId": "Pzd0ExNVHkyZLiYN",
|
||||
"clientSecret": "W7X6UvBaho+XOi1MUeCX6ewv2zTdSOV3Y7qC3p3675I=",
|
||||
"valid": "False",
|
||||
"from": ""
|
||||
},
|
||||
{
|
||||
"platform": "TV",
|
||||
"formats": "Normal/High/HiFi/Master",
|
||||
"clientId": "8SEZWa4J1NVC5U5Y",
|
||||
"clientSecret": "owUYDkxddz+9FpvGX24DlxECNtFEMBxipU0lBfrbq60=",
|
||||
"valid": "False",
|
||||
"from": "morguldir (https://github.com/morguldir/python-tidal/commit/50f1afcd2079efb2b4cf694ef5a7d67fdf619d09)"
|
||||
},
|
||||
{
|
||||
"platform": "Android Auto",
|
||||
"formats": "Normal/High/HiFi/Master",
|
||||
"clientId": "zU4XHVVkc2tDPo4t",
|
||||
"clientSecret": "VJKhDFqJPqvsPVNBV6ukXTJmwlvbttP7wlMlrc72se4=",
|
||||
"valid": "True",
|
||||
"from": "1nikolas (https://github.com/yaronzz/Tidal-Media-Downloader/pull/840)"
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
__API_KEYS__ = json.loads(__KEYS_JSON__)
|
||||
__ERROR_KEY__ = (
|
||||
{
|
||||
"platform": "None",
|
||||
"formats": "",
|
||||
"clientId": "",
|
||||
"clientSecret": "",
|
||||
"valid": "False",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def getNum():
|
||||
return len(__API_KEYS__["keys"])
|
||||
|
||||
|
||||
def getItem(index: int):
|
||||
if index < 0 or index >= len(__API_KEYS__["keys"]):
|
||||
return __ERROR_KEY__
|
||||
return __API_KEYS__["keys"][index]
|
||||
|
||||
|
||||
def isItemValid(index: int):
|
||||
item = getItem(index)
|
||||
return item["valid"] == "True"
|
||||
|
||||
|
||||
def getItems():
|
||||
return __API_KEYS__["keys"]
|
||||
|
||||
|
||||
def getLimitIndexs():
|
||||
array = []
|
||||
for i in range(len(__API_KEYS__["keys"])):
|
||||
array.append(str(i))
|
||||
return array
|
||||
|
||||
|
||||
def getVersion():
|
||||
return __API_KEYS__["version"]
|
||||
|
||||
|
||||
# Load from gist
|
||||
try:
|
||||
respond = requests.get("https://api.github.com/gists/48d01f5a24b4b7b37f19443977c22cd6")
|
||||
if respond.status_code == 200:
|
||||
content = respond.json()["files"]["tidal-api-key.json"]["content"]
|
||||
__API_KEYS__ = json.loads(content)
|
||||
except:
|
||||
pass
|
||||
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env python
|
||||
from typing import Annotated, Optional
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import typer
|
||||
from tidal_dl_ng.config import Settings, Tidal
|
||||
from tidal_dl_ng.constants import CTX_TIDAL, MediaType
|
||||
from tidal_dl_ng.helper.path import path_file_settings
|
||||
from tidal_dl_ng.helper.url import get_tidal_media_id, get_tidal_media_type
|
||||
from tidal_dl_ng.helper.wrapper import WrapperLogger
|
||||
from tidal_dl_ng.model.cfg import HelpSettings
|
||||
from rich.live import Live
|
||||
from rich.panel import Panel
|
||||
from rich.progress import BarColumn, Console, Progress, SpinnerColumn, TextColumn
|
||||
from rich.table import Table
|
||||
|
||||
from tidal_dl_ng.download import Download
|
||||
from tidal_dl_ng import __version__
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
|
||||
def version_callback(value: bool):
|
||||
if value:
|
||||
print(f"{__version__}")
|
||||
raise typer.Exit()
|
||||
|
||||
|
||||
@app.callback()
|
||||
def callback_app(
|
||||
ctx: typer.Context,
|
||||
version: Annotated[Optional[bool], typer.Option("--version", "-v", callback=version_callback, is_eager=True)] = None,
|
||||
):
|
||||
ctx.obj = {"tidal": None}
|
||||
|
||||
|
||||
@app.command(name="cfg")
|
||||
def settings_management(
|
||||
names: list[str] = None,
|
||||
editor: Annotated[
|
||||
bool, typer.Option("--editor", "-e", help="Open the settings file in your default editor.")
|
||||
] = False,
|
||||
):
|
||||
"""
|
||||
Print or set an option.
|
||||
If no arguments are given, all options will be listed.
|
||||
If only one argument is given, the value will be printed for this option.
|
||||
To set a value for an option simply pass the value as the second argument
|
||||
|
||||
:param names: (Optional) None (list all options), one (list the value only for this option) or two arguments
|
||||
(set the value for the option).
|
||||
"""
|
||||
if editor:
|
||||
config_path: Path = Path(path_file_settings())
|
||||
|
||||
if not config_path.is_file():
|
||||
config_path.write_text('{"version": "1.0.0"}')
|
||||
|
||||
config_file_str = str(config_path)
|
||||
|
||||
typer.launch(config_file_str)
|
||||
else:
|
||||
settings = Settings()
|
||||
d_settings = settings.data.to_dict()
|
||||
|
||||
if names:
|
||||
if names[0] not in d_settings:
|
||||
print(f'Option "{names[0]}" is not valid!')
|
||||
else:
|
||||
if len(names) == 1:
|
||||
print(f'{names[0]}: "{d_settings[names[0]]}"')
|
||||
elif len(names) > 1:
|
||||
settings.set_option(names[0], names[1])
|
||||
settings.save()
|
||||
else:
|
||||
help_settings: dict = HelpSettings().to_dict()
|
||||
table = Table(title=f"Config: {path_file_settings()}")
|
||||
table.add_column("Key", style="cyan", no_wrap=True)
|
||||
table.add_column("Value", style="magenta")
|
||||
table.add_column("Description", style="green")
|
||||
|
||||
# Iterate over the attributes of the dataclass
|
||||
for key, value in sorted(d_settings.items()):
|
||||
table.add_row(key, str(value), help_settings[key])
|
||||
|
||||
console = Console()
|
||||
console.print(table)
|
||||
|
||||
|
||||
@app.command(name="login")
|
||||
def login(ctx: typer.Context) -> bool:
|
||||
print("Let us check, if you are already logged in... ", end="")
|
||||
|
||||
settings = Settings()
|
||||
tidal = Tidal(settings)
|
||||
result = tidal.login(print)
|
||||
ctx.obj[CTX_TIDAL] = tidal
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@app.command(name="dl")
|
||||
def download(
|
||||
ctx: typer.Context,
|
||||
urls_or_ids: Annotated[Optional[list[str]], typer.Argument()] = None,
|
||||
list_urls: Annotated[
|
||||
Optional[Path],
|
||||
typer.Option(
|
||||
"--list",
|
||||
"-l",
|
||||
exists=True,
|
||||
file_okay=True,
|
||||
dir_okay=False,
|
||||
writable=False,
|
||||
readable=True,
|
||||
resolve_path=True,
|
||||
help="List with URLs to download. One per line",
|
||||
),
|
||||
] = None,
|
||||
):
|
||||
if not urls_or_ids:
|
||||
if list_urls:
|
||||
text = list_urls.read_text()
|
||||
urls_or_ids = text.splitlines()
|
||||
else:
|
||||
print("Provide either URLs, IDs or a file containing URLs (one per line).")
|
||||
|
||||
raise typer.Abort()
|
||||
|
||||
ctx.invoke(login, ctx)
|
||||
|
||||
dl = Download(ctx.obj[CTX_TIDAL].session, ctx.obj[CTX_TIDAL].settings.data.skip_existing)
|
||||
settings: Settings = Settings()
|
||||
media_type: MediaType = None
|
||||
progress: Progress = Progress(
|
||||
"{task.description}",
|
||||
SpinnerColumn(),
|
||||
BarColumn(),
|
||||
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
|
||||
)
|
||||
progress_table = Table.grid()
|
||||
fn_logger = WrapperLogger(progress.print)
|
||||
|
||||
progress_table.add_row(Panel.fit(progress, title="Download Progress", border_style="green", padding=(2, 2)))
|
||||
|
||||
for item in urls_or_ids:
|
||||
if "http" in item:
|
||||
media_name = get_tidal_media_type(item)
|
||||
id_item = get_tidal_media_id(item)
|
||||
else:
|
||||
media_name = False
|
||||
id_item = item
|
||||
|
||||
if not media_name:
|
||||
print(f"It seems like that you have supplied an invalid URL: {item}")
|
||||
|
||||
continue
|
||||
|
||||
with Live(progress_table, refresh_per_second=10):
|
||||
# TODO: Fix media type
|
||||
if media_name in ["track", "video"]:
|
||||
if media_name == "track":
|
||||
file_template = settings.data.format_track
|
||||
media_type = MediaType.Track
|
||||
elif media_name == "video":
|
||||
file_template = settings.data.format_video
|
||||
media_type = MediaType.Video
|
||||
|
||||
dl.item(
|
||||
id=id_item,
|
||||
media_type=media_type,
|
||||
path_base=settings.data.download_base_path,
|
||||
file_template=file_template,
|
||||
progress=progress,
|
||||
fn_logger=fn_logger
|
||||
)
|
||||
elif media_name in ["album", "playlist", "mix"]:
|
||||
# TODO: Handle mixes.
|
||||
file_template: str | bool = False
|
||||
|
||||
if media_name == "album":
|
||||
file_template = settings.data.format_album
|
||||
media_type = MediaType.Album
|
||||
elif media_name == "playlist":
|
||||
file_template = settings.data.format_playlist
|
||||
media_type = MediaType.Playlist
|
||||
elif media_name == "mix":
|
||||
file_template = settings.data.format_mix
|
||||
media_type = MediaType.Mix
|
||||
|
||||
dl.list(
|
||||
id_media=id_item,
|
||||
media_type=media_type,
|
||||
path_base=settings.data.download_base_path,
|
||||
file_template=file_template,
|
||||
video_download=ctx.obj[CTX_TIDAL].settings.data.video_download,
|
||||
progress=progress,
|
||||
download_delay=settings.data.download_delay,
|
||||
fn_logger=fn_logger,
|
||||
)
|
||||
|
||||
progress.stop()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@app.command()
|
||||
def gui(ctx: typer.Context):
|
||||
from tidal_dl_ng.gui import gui_activate
|
||||
|
||||
ctx.invoke(login, ctx)
|
||||
gui_activate(ctx.obj[CTX_TIDAL])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
@@ -0,0 +1,132 @@
|
||||
from typing import Any
|
||||
|
||||
from collections.abc import Callable
|
||||
from json import JSONDecodeError
|
||||
|
||||
import tidalapi
|
||||
from tidal_dl_ng.helper.decorator import SingletonMeta
|
||||
from tidal_dl_ng.helper.path import path_file_settings, path_file_token
|
||||
from tidal_dl_ng.model.cfg import Settings as ModelSettings
|
||||
from tidal_dl_ng.model.cfg import Token as ModelToken
|
||||
from requests import HTTPError
|
||||
|
||||
|
||||
class BaseConfig:
|
||||
data: ModelSettings | ModelToken = None
|
||||
file_path: str = None
|
||||
cls_model: object = None
|
||||
|
||||
def save(self) -> None:
|
||||
data_json = self.data.to_json()
|
||||
|
||||
with open(self.file_path, encoding="utf-8", mode="w") as f:
|
||||
f.write(data_json)
|
||||
|
||||
def set_option(self, key: str, value: Any) -> None:
|
||||
setattr(self.data, key, value)
|
||||
|
||||
def read(self, path: str) -> bool:
|
||||
result = False
|
||||
|
||||
try:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
settings_json = f.read()
|
||||
|
||||
self.data = self.cls_model.from_json(settings_json)
|
||||
result = True
|
||||
except (JSONDecodeError, TypeError, FileNotFoundError):
|
||||
self.data = self.cls_model()
|
||||
self.save()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class Settings(BaseConfig, metaclass=SingletonMeta):
|
||||
cls_model = ModelSettings
|
||||
data = None
|
||||
|
||||
def __init__(self):
|
||||
self.file_path = path_file_settings()
|
||||
self.read(self.file_path)
|
||||
|
||||
|
||||
class Tidal(BaseConfig, metaclass=SingletonMeta):
|
||||
cls_model = ModelToken
|
||||
session: tidalapi.Session = None
|
||||
data: ModelToken = None
|
||||
token_from_storage: bool = False
|
||||
settings: Settings = None
|
||||
|
||||
def __init__(self, settings: Settings = None):
|
||||
self.session = tidalapi.Session()
|
||||
self.session.video_quality = tidalapi.VideoQuality.high
|
||||
self.file_path = path_file_token()
|
||||
self.token_from_storage = self.read(self.file_path)
|
||||
self.login_token()
|
||||
|
||||
if settings:
|
||||
self.settings = settings
|
||||
self.settings_apply()
|
||||
|
||||
def settings_apply(self, settings: Settings = None) -> bool:
|
||||
if settings:
|
||||
self.settings = settings
|
||||
|
||||
self.session.audio_quality = self.settings.data.quality_audio
|
||||
|
||||
return True
|
||||
|
||||
def login_token(self) -> bool:
|
||||
result = False
|
||||
|
||||
if self.token_from_storage:
|
||||
try:
|
||||
result = self.session.load_oauth_session(
|
||||
self.data.token_type, self.data.access_token, self.data.refresh_token, self.data.expiry_time
|
||||
)
|
||||
except HTTPError:
|
||||
result = False
|
||||
|
||||
return result
|
||||
|
||||
def login_oauth_start(self, function=print) -> None:
|
||||
self.session.login_oauth_simple(function)
|
||||
|
||||
def login_oauth_finish(self) -> bool:
|
||||
result = self.session.check_login()
|
||||
|
||||
if result:
|
||||
self.token_persist()
|
||||
|
||||
return result
|
||||
|
||||
def token_persist(self) -> None:
|
||||
self.set_option("token_type", self.session.token_type)
|
||||
self.set_option("access_token", self.session.access_token)
|
||||
self.set_option("refresh_token", self.session.refresh_token)
|
||||
self.set_option("expiry_time", self.session.expiry_time)
|
||||
self.save()
|
||||
|
||||
def login(self, fn_print: Callable) -> bool:
|
||||
is_token = self.login_token()
|
||||
result = False
|
||||
|
||||
if is_token:
|
||||
fn_print("Yep, looks good! You are logged in.")
|
||||
|
||||
result = True
|
||||
elif not is_token:
|
||||
fn_print("You either do not have a token or your token is invalid.")
|
||||
fn_print("No worries, we will handle this...")
|
||||
self.login_oauth_start(fn_print)
|
||||
|
||||
is_login = self.login_oauth_finish()
|
||||
|
||||
if is_login:
|
||||
fn_print("The login was successful. I have stored your credentials (token).")
|
||||
|
||||
result = True
|
||||
else:
|
||||
fn_print("Something went wrong. Did you login using your browser correctly? May try again...")
|
||||
|
||||
return result
|
||||
@@ -0,0 +1,18 @@
|
||||
from enum import Enum
|
||||
|
||||
CTX_TIDAL: str = "tidal"
|
||||
|
||||
|
||||
class QualityVideo(Enum):
|
||||
P360 = 360
|
||||
P480 = 480
|
||||
P720 = 720
|
||||
P1080 = 1080
|
||||
|
||||
|
||||
class MediaType(Enum):
|
||||
Track = "track"
|
||||
Video = "video"
|
||||
Playlist = "playlist"
|
||||
Album = "album"
|
||||
Mix = "mix"
|
||||
@@ -0,0 +1,331 @@
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
from logging import Logger
|
||||
from requests.exceptions import HTTPError
|
||||
from uuid import uuid4
|
||||
|
||||
import ffmpeg
|
||||
import m3u8
|
||||
import requests
|
||||
from tidal_dl_ng.config import Settings
|
||||
from tidal_dl_ng.constants import MediaType
|
||||
from tidal_dl_ng.helper.decryption import decrypt_file, decrypt_security_token
|
||||
from tidal_dl_ng.helper.exceptions import MediaUnknown
|
||||
from tidal_dl_ng.helper.path import check_file_exists, format_path_media, path_validate
|
||||
from tidal_dl_ng.helper.wrapper import WrapperLogger
|
||||
from tidal_dl_ng.metadata import Metadata
|
||||
from tidal_dl_ng.model.gui_data import ProgressBars
|
||||
from pathvalidate import sanitize_filepath
|
||||
from rich.progress import Progress
|
||||
from tidalapi import Album, Playlist, Session, Track, UserPlaylist, Video, Mix
|
||||
|
||||
|
||||
# TODO: Set appropriate client string and use it for video download.
|
||||
# https://github.com/globocom/m3u8#using-different-http-clients
|
||||
class RequestsClient:
|
||||
def download(self, uri, timeout=None, headers={}, verify_ssl=True):
|
||||
o = requests.get(uri, timeout=timeout, headers=headers)
|
||||
|
||||
return o.text, o.url
|
||||
|
||||
|
||||
class Download:
|
||||
# TODO: Implement download cover 1280.
|
||||
session: Session = None
|
||||
skip_existing: bool = False
|
||||
|
||||
def __init__(self, session: Session, skip_existing: bool = False):
|
||||
self.session = session
|
||||
self.skip_existing = skip_existing
|
||||
|
||||
def _video(self, video: Video, path_file: str) -> str | None:
|
||||
result: str | None = None
|
||||
m3u8_variant: m3u8.M3U8 = m3u8.load(video.get_url())
|
||||
m3u8_playlist: m3u8.M3U8 | bool = False
|
||||
settings: Settings = Settings()
|
||||
resolution_best: int = 0
|
||||
|
||||
if m3u8_variant.is_variant:
|
||||
for playlist in m3u8_variant.playlists:
|
||||
if resolution_best < playlist.stream_info.resolution[1]:
|
||||
resolution_best = playlist.stream_info.resolution[1]
|
||||
m3u8_playlist = m3u8.load(playlist.uri)
|
||||
|
||||
if settings.data.quality_video.value == playlist.stream_info.resolution[1]:
|
||||
break
|
||||
|
||||
if m3u8_playlist:
|
||||
with open(path_file, "wb") as f:
|
||||
for segment in m3u8_playlist.data["segments"]:
|
||||
url = segment["uri"]
|
||||
r = requests.get(url)
|
||||
|
||||
f.write(r.content)
|
||||
|
||||
result = path_file
|
||||
|
||||
return result
|
||||
|
||||
def item(
|
||||
self,
|
||||
path_base: str,
|
||||
fn_logger: Logger | WrapperLogger,
|
||||
id: str = None,
|
||||
file_template: str = None,
|
||||
media: Track | Video = None,
|
||||
media_type: MediaType = None,
|
||||
video_download: bool = True,
|
||||
progress_gui: ProgressBars = None,
|
||||
progress: Progress = None
|
||||
) -> (bool, str):
|
||||
if id:
|
||||
if media_type == MediaType.Track:
|
||||
media = Track(self.session, id)
|
||||
elif media_type == MediaType.Video:
|
||||
media = Video(self.session, id)
|
||||
|
||||
# If video download is not allowed
|
||||
if not video_download:
|
||||
return False, ""
|
||||
else:
|
||||
raise MediaUnknown
|
||||
else:
|
||||
media = media
|
||||
|
||||
if file_template:
|
||||
file_name_relative = format_path_media(file_template, media)
|
||||
path_file = os.path.abspath(os.path.normpath(os.path.join(path_base, file_name_relative)))
|
||||
else:
|
||||
path_file = os.path.abspath(os.path.normpath(format_path_media(path_base, media)))
|
||||
|
||||
if isinstance(media, Track):
|
||||
stream = media.stream()
|
||||
# TODO: Check for `manifest_mime_type'. It could be also xml.
|
||||
stream_manifest = json.loads(base64.b64decode(stream.manifest).decode("utf-8"))
|
||||
# TODO: Handle more than one dowload URL
|
||||
stream_url = stream_manifest["urls"][0]
|
||||
file_extension = self.get_file_extension(stream_url, stream_manifest["codecs"])
|
||||
elif isinstance(media, Video):
|
||||
file_extension = ".ts"
|
||||
|
||||
path_file = sanitize_filepath(path_file + file_extension)
|
||||
# Check if path & filename longer than the OS allows. Shorten if necessary.
|
||||
validation_result, path_file = path_validate(path_file, True)
|
||||
|
||||
download_skip = check_file_exists(path_file) if self.skip_existing else False
|
||||
|
||||
if not download_skip:
|
||||
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmp_path_dir:
|
||||
tmp_path_file = os.path.join(tmp_path_dir, str(uuid4()) + file_extension)
|
||||
|
||||
if isinstance(media, Track):
|
||||
# TODO: Refactor to separate method.
|
||||
if progress_gui is None:
|
||||
progress_stdout: bool = True
|
||||
else:
|
||||
progress_stdout: bool = False
|
||||
progress_gui.item_name.emit(media.name)
|
||||
|
||||
try:
|
||||
# Streaming, so we can iterate over the response.
|
||||
r = requests.get(stream_url, stream=True)
|
||||
r.raise_for_status()
|
||||
total_size_in_bytes = int(r.headers.get("content-length", 0))
|
||||
block_size = 4096
|
||||
p_task = progress.add_task(
|
||||
f"[blue]Item '{media.name[:30]}'",
|
||||
total=total_size_in_bytes / block_size,
|
||||
visible=progress_stdout,
|
||||
)
|
||||
|
||||
while not progress.tasks[p_task].finished:
|
||||
with open(tmp_path_file, "wb") as f:
|
||||
for data in r.iter_content(chunk_size=block_size):
|
||||
f.write(data)
|
||||
progress.advance(p_task, advance=1)
|
||||
|
||||
if not progress_stdout:
|
||||
progress_gui.item.emit(progress.tasks[p_task].percentage)
|
||||
except HTTPError:
|
||||
# TODO: Handle Exception...
|
||||
pass
|
||||
|
||||
needs_decryption = self.is_encrypted(stream_manifest)
|
||||
|
||||
if needs_decryption:
|
||||
key, nonce = decrypt_security_token(stream_manifest["encryptionKey"])
|
||||
tmp_path_file_decrypted = tmp_path_file + "_decrypted"
|
||||
decrypt_file(tmp_path_file, tmp_path_file_decrypted, key, nonce)
|
||||
else:
|
||||
tmp_path_file_decrypted = tmp_path_file
|
||||
|
||||
self.metadata_write(media, tmp_path_file_decrypted)
|
||||
elif isinstance(media, Video):
|
||||
tmp_path_file_decrypted = self._video(media, tmp_path_file)
|
||||
|
||||
# TODO: Check if is possible to write metadata to MPEG Transport Stream files.
|
||||
# TODO: Make optional.
|
||||
if True:
|
||||
tmp_path_file_decrypted = self._video_convert(tmp_path_file_decrypted)
|
||||
path_file = os.path.splitext(path_file)[0] + ".mp4"
|
||||
|
||||
os.makedirs(os.path.dirname(path_file), exist_ok=True)
|
||||
shutil.move(tmp_path_file_decrypted, path_file)
|
||||
else:
|
||||
fn_logger.debug(f"Download skipped, since file exists: '{path_file}'")
|
||||
|
||||
return not download_skip, path_file
|
||||
|
||||
def cover_url(self, sid: str, width: int = 320, height: int = 320):
|
||||
if sid is None:
|
||||
return ""
|
||||
|
||||
return f"https://resources.tidal.com/images/{sid.replace('-', '/')}/{int(width)}x{int(height)}.jpg"
|
||||
|
||||
def cover_data(self, sid, width: int = 320, height: int = 320):
|
||||
url = self.cover_url(sid, width, height)
|
||||
|
||||
try:
|
||||
result: str = requests.get(url).content
|
||||
except:
|
||||
result: str = ""
|
||||
|
||||
return result
|
||||
|
||||
def metadata_write(self, track: Track, path_file: str):
|
||||
result: bool = False
|
||||
release_date: str = track.album.release_date.strftime("%Y-%m-%d") if track.album.release_date else ""
|
||||
copy_right: str = track.copyright if track.copyright else ""
|
||||
|
||||
try:
|
||||
lyrics: str = track.lyrics().text if hasattr(track, "lyrics") else ""
|
||||
except HTTPError:
|
||||
lyrics: str = ""
|
||||
|
||||
m: Metadata = Metadata(
|
||||
path_file=path_file,
|
||||
lyrics=lyrics,
|
||||
copy_right=copy_right,
|
||||
title=track.name,
|
||||
artists=[artist.name for artist in track.artists],
|
||||
album=track.album.name,
|
||||
tracknumber=track.track_num,
|
||||
date=release_date,
|
||||
isrc=track.isrc,
|
||||
albumartist=track.artist.name,
|
||||
totaltrack=track.album.num_tracks if track.album.num_tracks else 1,
|
||||
totaldisc=track.album.num_volumes if track.album.num_volumes else 1,
|
||||
discnumber=track.volume_num,
|
||||
url_cover=self.cover_url(track.album.cover),
|
||||
)
|
||||
|
||||
m.save()
|
||||
|
||||
result = True
|
||||
|
||||
return result
|
||||
|
||||
def list(
|
||||
self,
|
||||
path_base: str,
|
||||
fn_logger: Logger | WrapperLogger,
|
||||
id_media: str = None,
|
||||
media_type: MediaType = None,
|
||||
file_template: str = None,
|
||||
list_media: Album | Playlist | UserPlaylist | Mix = None,
|
||||
video_download: bool = False,
|
||||
progress_gui: ProgressBars = None,
|
||||
progress: Progress = None,
|
||||
download_delay: bool = True,
|
||||
):
|
||||
if not list_media:
|
||||
if media_type == MediaType.Album:
|
||||
list_media = Album(self.session, id_media)
|
||||
elif media_type == MediaType.Playlist:
|
||||
list_media = Playlist(self.session, id_media)
|
||||
elif media_type == MediaType.Mix:
|
||||
list_media = Mix(self.session, id_media)
|
||||
else:
|
||||
raise MediaUnknown
|
||||
|
||||
if file_template:
|
||||
file_name_relative = format_path_media(file_template, list_media)
|
||||
path_file = path_base
|
||||
else:
|
||||
file_name_relative = file_template
|
||||
path_file = format_path_media(path_base, list_media)
|
||||
|
||||
# TODO: Extend with pagination support: Iterate through `items` and `tracks`until len(returned list) == 0
|
||||
if isinstance(list_media, Mix):
|
||||
items = list_media.items()
|
||||
list_media_name = list_media.title[:30]
|
||||
elif video_download:
|
||||
items = list_media.items(limit=100)
|
||||
list_media_name = list_media.name[:30]
|
||||
else:
|
||||
items = list_media.tracks(limit=999)
|
||||
list_media_name = list_media.name[:30]
|
||||
|
||||
if progress_gui is None:
|
||||
progress_stdout: bool = True
|
||||
else:
|
||||
progress_stdout: bool = False
|
||||
|
||||
p_task1 = progress.add_task(f"[green]List '{list_media_name}'", total=len(items), visible=progress_stdout)
|
||||
|
||||
while not progress.finished:
|
||||
for media in items:
|
||||
Progress()
|
||||
# TODO: Handle return value of `track` method.
|
||||
self.item(
|
||||
path_base=path_file,
|
||||
file_template=file_name_relative,
|
||||
media=media,
|
||||
progress_gui=progress_gui,
|
||||
progress=progress,
|
||||
fn_logger=fn_logger
|
||||
)
|
||||
progress.advance(p_task1)
|
||||
|
||||
if not progress_stdout:
|
||||
progress_gui.list_item.emit(progress.tasks[p_task1].percentage)
|
||||
|
||||
if download_delay:
|
||||
time_sleep: float = round(random.SystemRandom().uniform(2, 5), 1)
|
||||
|
||||
# TODO: Fix logging. Is not displayed in debug window.
|
||||
fn_logger.debug(f"Next download will start in {time_sleep} seconds.")
|
||||
time.sleep(time_sleep)
|
||||
|
||||
def is_encrypted(self, manifest: dict) -> bool:
|
||||
result = manifest["encryptionType"] != "NONE"
|
||||
|
||||
return result
|
||||
|
||||
def get_file_extension(self, stream_url: str, stream_codec: str) -> str:
|
||||
result = None
|
||||
|
||||
if ".flac" in stream_url:
|
||||
result = ".flac"
|
||||
elif ".mp4" in stream_url:
|
||||
if "ac4" in stream_codec or "mha1" in stream_codec:
|
||||
result = ".mp4"
|
||||
elif "flac" in stream_codec:
|
||||
result = ".flac"
|
||||
else:
|
||||
result = ".m4a"
|
||||
else:
|
||||
result = ".m4a"
|
||||
|
||||
return result
|
||||
|
||||
def _video_convert(self, path_file: str) -> str:
|
||||
path_file_out = os.path.splitext(path_file)[0] + ".mp4"
|
||||
result, _ = ffmpeg.input(path_file).output(path_file_out, map=0, c="copy").run()
|
||||
|
||||
return path_file_out
|
||||
@@ -0,0 +1,481 @@
|
||||
import math
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
|
||||
try:
|
||||
import qdarktheme
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
print("Qt dependencies missing. Cannot start GUI. Please execute: 'pip install pyside6 pyqtdarktheme'")
|
||||
sys.exit(1)
|
||||
|
||||
import coloredlogs.converter
|
||||
from rich.progress import Progress
|
||||
from tidalapi import Album, Mix, Playlist, Quality, Track, UserPlaylist, Video
|
||||
from tidalapi.session import SearchTypes
|
||||
from tidal_dl_ng.config import Settings, Tidal
|
||||
from tidal_dl_ng.constants import QualityVideo
|
||||
from tidal_dl_ng.download import Download
|
||||
from tidal_dl_ng.logger import XStream, logger_cli, logger_gui
|
||||
from tidal_dl_ng.model.gui_data import ProgressBars, ResultSearch
|
||||
from tidal_dl_ng.ui.main import Ui_MainWindow
|
||||
from tidal_dl_ng.ui.spinner import QtWaitingSpinner
|
||||
from tidal_dl_ng.worker import Worker
|
||||
|
||||
|
||||
# TODO: Make more use of Exceptions
|
||||
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
settings: Settings = None
|
||||
tidal: Tidal = None
|
||||
download: Download = None
|
||||
threadpool: QtCore.QThreadPool = None
|
||||
spinner: QtWaitingSpinner = None
|
||||
spinner_start: QtCore.Signal = QtCore.Signal(QtWidgets.QWidget)
|
||||
spinner_stop: QtCore.Signal = QtCore.Signal()
|
||||
pb_item: QtWidgets.QProgressBar = None
|
||||
s_item_advance: QtCore.Signal = QtCore.Signal(float)
|
||||
s_item_name: QtCore.Signal = QtCore.Signal(str)
|
||||
pb_list: QtWidgets.QProgressBar = None
|
||||
s_list_advance: QtCore.Signal = QtCore.Signal(float)
|
||||
|
||||
def __init__(self, tidal: Tidal | None = None):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
# self.setGeometry(50, 50, 500, 300)
|
||||
self.setWindowTitle("TIDAL Downloader Next Gen!")
|
||||
# TODO: Fix icons (make them visible).
|
||||
my_pixmap = QtGui.QPixmap("tidal_dl_ng/ui/icon.png")
|
||||
my_icon = QtGui.QIcon("tidal_dl_ng/ui/icon.png")
|
||||
self.setWindowIcon(my_icon)
|
||||
tray = QtWidgets.QSystemTrayIcon()
|
||||
tray.setIcon(my_icon)
|
||||
tray.setVisible(True)
|
||||
|
||||
# Logging redirect.
|
||||
XStream.stdout().messageWritten.connect(self._log_output)
|
||||
# XStream.stderr().messageWritten.connect(self._log_output)
|
||||
|
||||
self.settings = Settings()
|
||||
self.threadpool = QtCore.QThreadPool()
|
||||
|
||||
# TODO: Show GUI, create a progress bar showing the TIDAL querying progress.
|
||||
self._init_tree_results(self.tr_results)
|
||||
self._init_tree_lists(self.tr_lists_user)
|
||||
self._init_progressbar()
|
||||
self._populate_quality(self.cb_quality_audio, Quality)
|
||||
self._populate_quality(self.cb_quality_video, QualityVideo)
|
||||
self._populate_search_types(self.cb_search_type, SearchTypes)
|
||||
self.apply_settings(self.settings)
|
||||
self._init_signals()
|
||||
self.thread_it(self.init_tidal, tidal)
|
||||
|
||||
logger_gui.debug("Multithreading with maximum %d threads" % self.threadpool.maxThreadCount())
|
||||
logger_gui.debug("All setup.")
|
||||
|
||||
def init_tidal(self, tidal: Tidal = None):
|
||||
result: bool = False
|
||||
|
||||
if tidal:
|
||||
self.tidal = tidal
|
||||
result = True
|
||||
else:
|
||||
self.tidal = Tidal(self.settings)
|
||||
|
||||
while True:
|
||||
result = self.tidal.login(logger_gui.info)
|
||||
|
||||
if result:
|
||||
break
|
||||
|
||||
if result:
|
||||
self.download = Download(self.tidal.session, self.tidal.settings.data.skip_existing)
|
||||
|
||||
self.thread_it(self.populate_tree_lists, self.tidal)
|
||||
|
||||
def _init_progressbar(self):
|
||||
self.pb_list = QtWidgets.QProgressBar()
|
||||
self.pb_item = QtWidgets.QProgressBar()
|
||||
pbs = [self.pb_list, self.pb_item]
|
||||
|
||||
for pb in pbs:
|
||||
pb.setRange(0, 100)
|
||||
# self.pb_progress.setVisible()
|
||||
self.statusbar.addPermanentWidget(pb)
|
||||
|
||||
def progress_reset(self):
|
||||
self.pb_list.setValue(0)
|
||||
self.pb_item.setValue(0)
|
||||
|
||||
def _log_output(self, text):
|
||||
display_msg = coloredlogs.converter.convert(text)
|
||||
|
||||
cursor: QtGui.QTextCursor = self.te_debug.textCursor()
|
||||
cursor.movePosition(QtGui.QTextCursor.End)
|
||||
cursor.insertHtml(display_msg)
|
||||
|
||||
self.te_debug.setTextCursor(cursor)
|
||||
self.te_debug.ensureCursorVisible()
|
||||
|
||||
def _populate_quality(self, ui_target: QtWidgets.QComboBox, options: type[Quality | QualityVideo]):
|
||||
for item in options:
|
||||
ui_target.addItem(item.name, item)
|
||||
|
||||
def _populate_search_types(self, ui_target: QtWidgets.QComboBox, options: SearchTypes):
|
||||
for item in options:
|
||||
if item and not item.__name__ == "Artist":
|
||||
ui_target.addItem(item.__name__, item)
|
||||
|
||||
self.cb_search_type.setCurrentIndex(1)
|
||||
|
||||
def _init_tree_results(self, tree: QtWidgets.QTableWidget):
|
||||
tree.setColumnHidden(5, True)
|
||||
|
||||
def populate_tree_lists(self, tidal: Tidal):
|
||||
# Start loading spinner
|
||||
self.spinner_start.emit(self.tr_lists_user)
|
||||
self.tr_results.clear()
|
||||
|
||||
# TODO: Refactor list item names to constants.
|
||||
twi_playlists: QtWidgets.QTableWidgetItem = self.tr_lists_user.findItems(
|
||||
"Playlists", QtCore.Qt.MatchExactly, 0
|
||||
)[0]
|
||||
twi_mixes: QtWidgets.QTableWidgetItem = self.tr_lists_user.findItems("Favorites", QtCore.Qt.MatchExactly, 0)[0]
|
||||
twi_favorites: QtWidgets.QTableWidgetItem = self.tr_lists_user.findItems("Mixes", QtCore.Qt.MatchExactly, 0)[0]
|
||||
|
||||
user_playlists: [Playlist | UserPlaylist] = tidal.session.user.playlist_and_favorite_playlists()
|
||||
user_mixes: [Mix] = tidal.session.mixes().categories[0].items
|
||||
user_all: [Playlist | UserPlaylist | Mix] = user_playlists + user_mixes
|
||||
|
||||
for item in user_all:
|
||||
if isinstance(item, UserPlaylist):
|
||||
twi_child = QtWidgets.QTreeWidgetItem(twi_playlists)
|
||||
name: str = item.name
|
||||
info: str = f"({item.num_tracks + item.num_videos} Tracks)"
|
||||
elif isinstance(item, Playlist):
|
||||
twi_child = QtWidgets.QTreeWidgetItem(twi_mixes)
|
||||
name: str = item.name
|
||||
info: str = f"({item.num_tracks + item.num_videos} Tracks) {item.description}"
|
||||
elif isinstance(item, Mix):
|
||||
twi_child = QtWidgets.QTreeWidgetItem(twi_favorites)
|
||||
name: str = item.title
|
||||
info: str = item.sub_title
|
||||
|
||||
twi_child.setText(0, name)
|
||||
twi_child.setText(1, info)
|
||||
twi_child.setData(3, QtCore.Qt.ItemDataRole.UserRole, item)
|
||||
|
||||
# Stop load spinner
|
||||
self.spinner_stop.emit()
|
||||
|
||||
def _init_tree_lists(self, tree: QtWidgets.QTreeWidget):
|
||||
tree.setColumnWidth(0, 200)
|
||||
tree.setColumnWidth(1, 300)
|
||||
tree.setColumnHidden(2, True)
|
||||
tree.expandAll()
|
||||
|
||||
# Connect the contextmenu
|
||||
tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||
tree.customContextMenuRequested.connect(self.menu_context_tree_lists)
|
||||
|
||||
def apply_settings(self, settings: Settings):
|
||||
l_cb = [
|
||||
{"element": self.cb_quality_audio, "setting": settings.data.quality_audio.name, "default_id": 1},
|
||||
{"element": self.cb_quality_video, "setting": settings.data.quality_video.name, "default_id": 0},
|
||||
]
|
||||
|
||||
for item in l_cb:
|
||||
idx = item["element"].findText(item["setting"])
|
||||
if idx > -1:
|
||||
item["element"].setCurrentIndex(idx)
|
||||
else:
|
||||
item["element"].setCurrentIndex(item["default_id"])
|
||||
|
||||
@QtCore.Slot(QtWidgets.QWidget)
|
||||
def on_spinner_start(self, parent: QtWidgets.QWidget):
|
||||
self.spinner = QtWaitingSpinner(parent, True, True)
|
||||
self.spinner.setColor(QtGui.QColor(255, 255, 255))
|
||||
self.spinner.start()
|
||||
|
||||
@QtCore.Slot()
|
||||
def on_spinner_stop(self):
|
||||
self.spinner.stop()
|
||||
self.spinner = None
|
||||
|
||||
def menu_context_tree_lists(self, point):
|
||||
# Infos about the node selected.
|
||||
index = self.tr_lists_user.indexAt(point)
|
||||
|
||||
# Do not open menu if something went wrong or a parent node is clicked.
|
||||
if not index.isValid() or not index.parent().data():
|
||||
return
|
||||
|
||||
# We build the menu.
|
||||
menu = QtWidgets.QMenu()
|
||||
action = menu.addAction("Dowloading Playlist", lambda: self.thread_download_list_media(point))
|
||||
|
||||
menu.exec(self.tr_lists_user.mapToGlobal(point))
|
||||
|
||||
def thread_download_list_media(self, point):
|
||||
self.thread_it(self.on_download_list_media, point)
|
||||
self.thread_it(self.list_items_show, point=point)
|
||||
|
||||
def on_download_list_media(self, point: QtCore.QPoint):
|
||||
item = self.tr_lists_user.itemAt(point)
|
||||
media = item.data(3, QtCore.Qt.ItemDataRole.UserRole)
|
||||
|
||||
# TODO: Implement disable download button etc.
|
||||
self.download_item(media, self.download)
|
||||
|
||||
def search_populate_results(self, query: str, type_media: SearchTypes):
|
||||
self.tr_results.clear()
|
||||
|
||||
results: [ResultSearch] = self.search(query, [type_media])
|
||||
|
||||
self.populate_tree_results(results)
|
||||
|
||||
def populate_tree_results(self, results: [ResultSearch]):
|
||||
self.tr_results.clear()
|
||||
|
||||
for item in results:
|
||||
# Format seconds to mm:ss.
|
||||
m, s = divmod(item.duration_sec, 60)
|
||||
duration: str = f"{m:02d}:{s:02d}"
|
||||
child = QtWidgets.QTreeWidgetItem()
|
||||
|
||||
child.setText(0, str(item.position))
|
||||
child.setText(1, item.artist)
|
||||
child.setText(2, item.title)
|
||||
child.setText(3, item.album)
|
||||
child.setText(4, duration)
|
||||
child.setData(5, QtCore.Qt.ItemDataRole.UserRole, item.obj)
|
||||
|
||||
self.tr_results.addTopLevelItem(child)
|
||||
|
||||
def search(self, query: str, types_media: SearchTypes) -> [ResultSearch]:
|
||||
result_search: [dict[str, *SearchTypes]] = self.tidal.session.search(query, models=types_media, limit=999)
|
||||
result: [ResultSearch] = []
|
||||
|
||||
for media_type, l_media in result_search.items():
|
||||
if isinstance(l_media, list):
|
||||
result = result + self.search_result_to_model(l_media)
|
||||
|
||||
return result
|
||||
|
||||
def search_result_to_model(self, items: [*SearchTypes]) -> [ResultSearch]:
|
||||
result = []
|
||||
|
||||
for idx, item in enumerate(items):
|
||||
if isinstance(item, Track):
|
||||
result_item: ResultSearch = ResultSearch(
|
||||
position=idx,
|
||||
artist=item.artist.name,
|
||||
title=item.name,
|
||||
album=item.album.name,
|
||||
duration_sec=item.duration,
|
||||
obj=item,
|
||||
)
|
||||
|
||||
result.append(result_item)
|
||||
elif isinstance(item, Video):
|
||||
result_item: ResultSearch = ResultSearch(
|
||||
position=idx,
|
||||
artist=item.artist.name,
|
||||
title=item.name,
|
||||
album=item.album.name if item.album else "",
|
||||
duration_sec=item.duration,
|
||||
obj=item,
|
||||
)
|
||||
|
||||
result.append(result_item)
|
||||
elif isinstance(item, Playlist):
|
||||
result_item: ResultSearch = ResultSearch(
|
||||
position=idx,
|
||||
artist=f"{item.promoted_artists[0].name}, ..." if item.promoted_artists else "",
|
||||
title=item.name,
|
||||
album="",
|
||||
duration_sec=item.duration,
|
||||
obj=item,
|
||||
)
|
||||
|
||||
result.append(result_item)
|
||||
elif isinstance(item, Album):
|
||||
result_item: ResultSearch = ResultSearch(
|
||||
position=idx,
|
||||
artist=item.artist.name,
|
||||
title="",
|
||||
album=item.name,
|
||||
duration_sec=item.duration,
|
||||
obj=item,
|
||||
)
|
||||
|
||||
result.append(result_item)
|
||||
|
||||
return result
|
||||
|
||||
def _init_signals(self):
|
||||
self.b_download.clicked.connect(lambda: self.thread_it(self.on_download_results))
|
||||
self.l_search.returnPressed.connect(
|
||||
lambda: self.search_populate_results(self.l_search.text(), self.cb_search_type.currentData())
|
||||
)
|
||||
self.b_search.clicked.connect(
|
||||
lambda: self.search_populate_results(self.l_search.text(), self.cb_search_type.currentData())
|
||||
)
|
||||
self.cb_quality_audio.currentIndexChanged.connect(self.quality_set_audio)
|
||||
self.cb_quality_video.currentIndexChanged.connect(self.quality_set_video)
|
||||
self.tr_lists_user.itemClicked.connect(self.on_list_items_show)
|
||||
self.spinner_start[QtWidgets.QWidget].connect(self.on_spinner_start)
|
||||
self.spinner_stop.connect(self.on_spinner_stop)
|
||||
self.s_item_advance.connect(self.progress_item)
|
||||
self.s_item_name.connect(self.progress_item_name)
|
||||
self.s_list_advance.connect(self.progress_list)
|
||||
|
||||
def progress_list(self, value: float):
|
||||
self.pb_list.setValue(int(math.ceil(value)))
|
||||
|
||||
def progress_item(self, value: float):
|
||||
self.pb_item.setValue(int(math.ceil(value)))
|
||||
|
||||
def progress_item_name(self, value: str):
|
||||
self.pb_item.setFormat(f"%p% {value}")
|
||||
|
||||
def progress_list_name(self, value: str):
|
||||
self.pb_list.setFormat(f"%p% {value}")
|
||||
|
||||
def quality_set_audio(self, index):
|
||||
self.settings.data.quality_audio = Quality(self.cb_quality_audio.itemData(index).value)
|
||||
self.settings.save()
|
||||
|
||||
if self.tidal:
|
||||
self.tidal.settings_apply()
|
||||
|
||||
def quality_set_video(self, index):
|
||||
self.settings.data.quality_video = QualityVideo(self.cb_quality_video.itemData(index).value)
|
||||
self.settings.save()
|
||||
|
||||
if self.tidal:
|
||||
self.tidal.settings_apply()
|
||||
|
||||
def on_list_items_show(self, item: QtWidgets.QTreeWidgetItem):
|
||||
media_list: Album | Playlist = item.data(3, QtCore.Qt.ItemDataRole.UserRole)
|
||||
|
||||
# Only if clicked item is not a top level item.
|
||||
if media_list:
|
||||
self.list_items_show(media_list)
|
||||
|
||||
def list_items_show(self, media_list: Album | Playlist | None = None, point: QtCore.QPoint | None = None):
|
||||
if point:
|
||||
item = self.tr_lists_user.itemAt(point)
|
||||
media_list = item.data(3, QtCore.Qt.ItemDataRole.UserRole)
|
||||
|
||||
media_items = media_list.items()
|
||||
result = self.search_result_to_model(media_items)
|
||||
|
||||
self.populate_tree_results(result)
|
||||
|
||||
def thread_it(self, fn: Callable, *args, **kwargs):
|
||||
# Any other args, kwargs are passed to the run function
|
||||
worker = Worker(fn, *args, **kwargs)
|
||||
|
||||
# Execute
|
||||
self.threadpool.start(worker)
|
||||
|
||||
def on_download_results(self):
|
||||
self.b_download.setEnabled(False)
|
||||
self.b_download.setText(f"Downloading...")
|
||||
|
||||
items: [QtWidgets.QTreeWidgetItem] = self.tr_results.selectedItems()
|
||||
|
||||
if len(items) == 0:
|
||||
logger_gui.error("Please select a row first.")
|
||||
else:
|
||||
for item in items:
|
||||
media: Track | Album | Playlist | Video = item.data(5, QtCore.Qt.ItemDataRole.UserRole)
|
||||
|
||||
result_dl: bool = self.download_item(media, self.download)
|
||||
|
||||
self.b_download.setText(f"Download")
|
||||
self.b_download.setEnabled(True)
|
||||
|
||||
def download_item(self, media: Track | Album | Playlist | Video | Mix, dl: Download) -> bool:
|
||||
# TODO: Refactor this. Move this logic to `Download` class and provide a generic interface.
|
||||
self.progress_reset()
|
||||
self.statusbar.showMessage("Download started...")
|
||||
|
||||
data_pb: ProgressBars = ProgressBars(
|
||||
item=self.s_item_advance, list_item=self.s_list_advance, item_name=self.s_item_name
|
||||
)
|
||||
progress: Progress = Progress()
|
||||
|
||||
if isinstance(media, Track) or isinstance(media, Video):
|
||||
if isinstance(media, Track):
|
||||
file_template: str = self.settings.data.format_track
|
||||
elif isinstance(media, Video):
|
||||
file_template: str = self.settings.data.format_video
|
||||
|
||||
result_download, download_path_file = dl.item(
|
||||
media=media,
|
||||
path_base=self.settings.data.download_base_path,
|
||||
file_template=file_template,
|
||||
progress_gui=data_pb,
|
||||
progress=progress,
|
||||
fn_logger=logger_gui
|
||||
)
|
||||
|
||||
if result_download:
|
||||
logger_gui.info(f"Download successful: {download_path_file}")
|
||||
else:
|
||||
logger_gui.info(f"Download skipped (file exists): {download_path_file}")
|
||||
elif isinstance(media, Album) or isinstance(media, Playlist) or isinstance(media, Mix):
|
||||
file_template: str | bool = False
|
||||
|
||||
if isinstance(media, Album):
|
||||
file_template: str = self.settings.data.format_album
|
||||
progress_name = media.name
|
||||
elif isinstance(media, Playlist):
|
||||
file_template: str = self.settings.data.format_playlist
|
||||
progress_name = media.name
|
||||
elif isinstance(media, Mix):
|
||||
file_template: str = self.settings.data.format_mix
|
||||
progress_name = media.title
|
||||
else:
|
||||
progress_name = "List N/A"
|
||||
|
||||
self.progress_list_name(progress_name)
|
||||
|
||||
dl.list(
|
||||
path_base=self.settings.data.download_base_path,
|
||||
file_template=file_template,
|
||||
list_media=media,
|
||||
video_download=self.settings.data.video_download,
|
||||
progress_gui=data_pb,
|
||||
progress=progress,
|
||||
download_delay=self.settings.data.download_delay,
|
||||
fn_logger=logger_gui,
|
||||
)
|
||||
|
||||
self.statusbar.showMessage("Download finished.", 2000)
|
||||
progress.stop()
|
||||
|
||||
# TODO: Refactor to useful return value.
|
||||
return True
|
||||
|
||||
def progress_reset(self):
|
||||
self.pb_list.setValue(0)
|
||||
self.pb_item.setValue(0)
|
||||
|
||||
|
||||
# TODO: Comment with Google Docstrings.
|
||||
def gui_activate(tidal: Tidal | None = None):
|
||||
qdarktheme.enable_hi_dpi()
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
qdarktheme.setup_theme()
|
||||
|
||||
window = MainWindow(tidal)
|
||||
window.show()
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
gui_activate()
|
||||
@@ -0,0 +1,19 @@
|
||||
class SingletonMeta(type):
|
||||
"""
|
||||
The Singleton class can be implemented in different ways in Python. Some
|
||||
possible methods include: base class, decorator, metaclass. We will use the
|
||||
metaclass because it is best suited for this purpose.
|
||||
"""
|
||||
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
"""
|
||||
Possible changes to the value of the `__init__` argument do not affect
|
||||
the returned instance.
|
||||
"""
|
||||
if cls not in cls._instances:
|
||||
instance = super().__call__(*args, **kwargs)
|
||||
cls._instances[cls] = instance
|
||||
|
||||
return cls._instances[cls]
|
||||
@@ -0,0 +1,53 @@
|
||||
import base64
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util import Counter
|
||||
|
||||
|
||||
def decrypt_security_token(security_token: str) -> (str, str):
|
||||
"""
|
||||
Decrypts security token into key and nonce pair
|
||||
|
||||
security_token should match the securityToken value from the web response
|
||||
"""
|
||||
|
||||
# Do not change this
|
||||
master_key = "UIlTTEMmmLfGowo/UC60x2H45W6MdGgTRfo/umg4754="
|
||||
|
||||
# Decode the base64 strings to ascii strings
|
||||
master_key = base64.b64decode(master_key)
|
||||
security_token = base64.b64decode(security_token)
|
||||
|
||||
# Get the IV from the first 16 bytes of the securityToken
|
||||
iv = security_token[:16]
|
||||
encrypted_st = security_token[16:]
|
||||
|
||||
# Initialize decryptor
|
||||
decryptor = AES.new(master_key, AES.MODE_CBC, iv)
|
||||
|
||||
# Decrypt the security token
|
||||
decrypted_st = decryptor.decrypt(encrypted_st)
|
||||
|
||||
# Get the audio stream decryption key and nonce from the decrypted security token
|
||||
key = decrypted_st[:16]
|
||||
nonce = decrypted_st[16:24]
|
||||
|
||||
return key, nonce
|
||||
|
||||
|
||||
def decrypt_file(path_file_encrypted: str, path_file_destination: str, key: str, nonce: str) -> None:
|
||||
"""
|
||||
Decrypts an encrypted MQA file given the file, key and nonce
|
||||
"""
|
||||
|
||||
# Initialize counter and file decryptor
|
||||
counter = Counter.new(64, prefix=nonce, initial_value=0)
|
||||
decryptor = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
|
||||
# Open and decrypt
|
||||
with open(path_file_encrypted, "rb") as f_src:
|
||||
audio_decrypted = decryptor.decrypt(f_src.read())
|
||||
|
||||
# Replace with decrypted file
|
||||
with open(path_file_destination, "wb") as f_dst:
|
||||
f_dst.write(audio_decrypted)
|
||||
@@ -0,0 +1,6 @@
|
||||
class LoginError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class MediaUnknown(Exception):
|
||||
pass
|
||||
@@ -0,0 +1,177 @@
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from pathvalidate import sanitize_filename
|
||||
from tidalapi import Album, Playlist, Track, UserPlaylist, Video, Mix
|
||||
|
||||
|
||||
def path_base():
|
||||
if "XDG_CONFIG_HOME" in os.environ:
|
||||
return os.environ["XDG_CONFIG_HOME"]
|
||||
elif "HOME" in os.environ:
|
||||
return os.environ["HOME"]
|
||||
elif "HOMEDRIVE" in os.environ and "HOMEPATH" in os.environ:
|
||||
return os.path.join(os.environ["HOMEDRIVE"], os.environ["HOMEPATH"])
|
||||
else:
|
||||
return os.path.abspath("./")
|
||||
|
||||
|
||||
def path_file_log():
|
||||
return os.path.join(path_base(), ".tidal-dl-ng.log")
|
||||
|
||||
|
||||
def path_file_token():
|
||||
return os.path.join(path_base(), ".tidal-dl-ng_token.json")
|
||||
|
||||
|
||||
def path_file_settings():
|
||||
return os.path.join(path_base(), ".tidal-dl-ng_settings.json")
|
||||
|
||||
|
||||
def format_path_media(fmt_template: str, media: Track | Album | Playlist | UserPlaylist | Video | Mix) -> str:
|
||||
result = fmt_template
|
||||
|
||||
# Search track format template for placeholder.
|
||||
regex = r"\{(.+?)\}"
|
||||
matches = re.finditer(regex, fmt_template, re.MULTILINE)
|
||||
fn_format = get_fn_format(media)
|
||||
|
||||
for _matchNum, match in enumerate(matches, start=1):
|
||||
template_str = match.group()
|
||||
result_fmt = fn_format(match.group(1), media)
|
||||
|
||||
if result_fmt:
|
||||
value = sanitize_filename(result_fmt)
|
||||
result = result.replace(template_str, value)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def format_str_track(name: str, media: Track) -> str | bool:
|
||||
result: str | bool = False
|
||||
|
||||
if name == "track_num":
|
||||
result = str(media.track_num).rjust(2, "0")
|
||||
elif name == "artist_name":
|
||||
result = ", ".join(artist.name for artist in media.artists)
|
||||
elif name == "track_title":
|
||||
result = media.name
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def format_str_album(name: str, media: Album) -> str | bool:
|
||||
result: str | bool = False
|
||||
|
||||
if name == "album_title":
|
||||
result = media.name
|
||||
elif name == "artist_name":
|
||||
result = media.artist.name
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def format_str_playlist(name: str, media: Playlist) -> str | bool:
|
||||
result: str | bool = False
|
||||
|
||||
if name == "playlist_name":
|
||||
result = media.name
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def format_str_mix(name: str, media: Mix) -> str | bool:
|
||||
result: str | bool = False
|
||||
|
||||
if name == "mix_name":
|
||||
result = media.title
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def format_str_video(name: str, media: Video) -> str | bool:
|
||||
result: str | bool = False
|
||||
|
||||
if name == "artist_name":
|
||||
result = ", ".join(artist.name for artist in media.artists)
|
||||
elif name == "track_title":
|
||||
result = media.name
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_fn_format(media: Track | Album | Playlist | UserPlaylist | Video | Mix) -> Callable:
|
||||
result = None
|
||||
|
||||
if isinstance(media, Track):
|
||||
result = format_str_track
|
||||
elif isinstance(media, Album):
|
||||
result = format_str_album
|
||||
elif isinstance(media, (Playlist, UserPlaylist)):
|
||||
result = format_str_playlist
|
||||
elif isinstance(media, Mix):
|
||||
result = format_str_mix
|
||||
elif isinstance(media, Video):
|
||||
result = format_str_video
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def length_max_name_file() -> int:
|
||||
system = platform.system()
|
||||
result: int = 255
|
||||
|
||||
try:
|
||||
if system in ['Darwin', 'Linux']:
|
||||
result: int = os.pathconf('/', 'PC_NAME_MAX')
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def length_max_name_path() -> int:
|
||||
system = platform.system()
|
||||
result: int = 255
|
||||
|
||||
try:
|
||||
if system in ['Darwin', 'Linux']:
|
||||
result: int = os.pathconf('/', 'PC_PATH_MAX')
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def path_validate(path_file: str, adapt: bool = False) -> (bool, str):
|
||||
result: bool = False
|
||||
length_max_path: int = length_max_name_path()
|
||||
length_max_file: int = length_max_name_file()
|
||||
path, file = os.path.split(path_file)
|
||||
filename, extension = os.path.splitext(file)
|
||||
|
||||
if len(path) >= length_max_path:
|
||||
result = False
|
||||
|
||||
if adapt:
|
||||
path = Path.home()
|
||||
|
||||
if len(file) >= length_max_file:
|
||||
result = False
|
||||
|
||||
if adapt:
|
||||
file = f'{filename[:length_max_file - len(extension + "_")]}_{extension}'
|
||||
|
||||
path_file = os.path.join(path, file)
|
||||
|
||||
return result, path_file
|
||||
|
||||
|
||||
def check_file_exists(path_file: str):
|
||||
result = pathlib.Path(path_file).is_file()
|
||||
|
||||
return result
|
||||
@@ -0,0 +1,15 @@
|
||||
def get_tidal_media_id(url_or_id_media: str) -> str:
|
||||
id_dirty = url_or_id_media.rsplit("/", 1)[-1]
|
||||
id = id_dirty.rsplit("?", 1)[0]
|
||||
|
||||
return id
|
||||
|
||||
|
||||
def get_tidal_media_type(url_media: str) -> str | bool:
|
||||
result = False
|
||||
url_split = url_media.split("/")[-2]
|
||||
|
||||
if len(url_split) > 1:
|
||||
result = url_media.split("/")[-2]
|
||||
|
||||
return result
|
||||
@@ -0,0 +1,23 @@
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
class WrapperLogger:
|
||||
fn_print: Callable = None
|
||||
|
||||
def __init__(self, fn_print: Callable):
|
||||
self.fn_print = fn_print
|
||||
|
||||
def debug(self, value):
|
||||
self.fn_print(value)
|
||||
|
||||
def warning(self, value):
|
||||
self.fn_print(value)
|
||||
|
||||
def info(self, value):
|
||||
self.fn_print(value)
|
||||
|
||||
def error(self, value):
|
||||
self.fn_print(value)
|
||||
|
||||
def critical(self, value):
|
||||
self.fn_print(value)
|
||||
@@ -0,0 +1,65 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import coloredlogs
|
||||
from PySide6 import QtCore
|
||||
|
||||
|
||||
class XStream(QtCore.QObject):
|
||||
_stdout = None
|
||||
_stderr = None
|
||||
messageWritten = QtCore.Signal(str)
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
def fileno(self):
|
||||
return -1
|
||||
|
||||
def write(self, msg):
|
||||
if not self.signalsBlocked():
|
||||
self.messageWritten.emit(msg)
|
||||
|
||||
@staticmethod
|
||||
def stdout():
|
||||
if not XStream._stdout:
|
||||
XStream._stdout = XStream()
|
||||
sys.stdout = XStream._stdout
|
||||
return XStream._stdout
|
||||
|
||||
@staticmethod
|
||||
def stderr():
|
||||
if not XStream._stderr:
|
||||
XStream._stderr = XStream()
|
||||
sys.stderr = XStream._stderr
|
||||
return XStream._stderr
|
||||
|
||||
|
||||
class QtHandler(logging.Handler):
|
||||
def __init__(self):
|
||||
logging.Handler.__init__(self)
|
||||
|
||||
def emit(self, record):
|
||||
record = self.format(record)
|
||||
|
||||
if record:
|
||||
# originally: XStream.stdout().write("{}\n".format(record))
|
||||
XStream.stdout().write("%s\n" % record)
|
||||
|
||||
|
||||
logger_gui = logging.getLogger(__name__)
|
||||
handler_qt: QtHandler = QtHandler()
|
||||
# log_fmt: str = "[%(asctime)s] %(levelname)s: %(message)s"
|
||||
log_fmt: str = "> %(message)s"
|
||||
# formatter = logging.Formatter(log_fmt)
|
||||
formatter = coloredlogs.ColoredFormatter(fmt=log_fmt)
|
||||
handler_qt.setFormatter(formatter)
|
||||
logger_gui.addHandler(handler_qt)
|
||||
logger_gui.setLevel(logging.DEBUG)
|
||||
|
||||
logger_cli = logging.getLogger(__name__)
|
||||
handler_stream: logging.StreamHandler = logging.StreamHandler()
|
||||
formatter = coloredlogs.ColoredFormatter(fmt=log_fmt)
|
||||
handler_stream.setFormatter(formatter)
|
||||
logger_cli.addHandler(handler_stream)
|
||||
logger_cli.setLevel(logging.DEBUG)
|
||||
@@ -0,0 +1,163 @@
|
||||
import pathlib
|
||||
|
||||
import mutagen
|
||||
import requests
|
||||
from mutagen import flac, mp4
|
||||
from mutagen.id3 import APIC, TALB, TCOM, TCOP, TDRC, TIT2, TOPE, TPE1, TRCK, TSRC, USLT
|
||||
|
||||
|
||||
class Metadata:
|
||||
path_file: str = None
|
||||
type_audio: str = None
|
||||
title: str = None
|
||||
album: str = None
|
||||
albumartist: str = None
|
||||
artists: [str] = None
|
||||
copy_right: str = None
|
||||
tracknumber: int = None
|
||||
discnumber: int = None
|
||||
totaldisc: int = None
|
||||
totaltrack: int = None
|
||||
date: str = None
|
||||
composer: [str] = None
|
||||
isrc: str = None
|
||||
lyrics: str = None
|
||||
path_cover: str = None
|
||||
url_cover: str = None
|
||||
m: mutagen.mp4.MP4 | mutagen.mp4.MP4 | mutagen.flac.FLAC = None
|
||||
|
||||
# TODO: What about videos?
|
||||
def __init__(
|
||||
self,
|
||||
path_file: str,
|
||||
type_audio: str = "",
|
||||
album: str = "",
|
||||
title: str = "",
|
||||
artists: [str] = [""],
|
||||
copy_right: str = "",
|
||||
tracknumber: int = 0,
|
||||
discnumber: int = 0,
|
||||
totaltrack: int = 0,
|
||||
totaldisc: int = 0,
|
||||
composer: [str] = [""],
|
||||
isrc: str = "",
|
||||
albumartist: str = "",
|
||||
date: str = "",
|
||||
lyrics: str = "",
|
||||
path_cover: str = "",
|
||||
url_cover: str = "",
|
||||
):
|
||||
self.path_file = path_file
|
||||
|
||||
if type_audio:
|
||||
self.type_audio = type_audio
|
||||
else:
|
||||
self.type_audio = pathlib.Path(self.path_file).suffix[1:]
|
||||
|
||||
self.title = title
|
||||
self.album = album
|
||||
self.albumartist = albumartist
|
||||
self.artists = artists
|
||||
self.copy_right = copy_right
|
||||
self.tracknumber = tracknumber
|
||||
self.discnumber = discnumber
|
||||
self.totaldisc = totaldisc
|
||||
self.totaltrack = totaltrack
|
||||
self.date = date
|
||||
self.composer = composer
|
||||
self.isrc = isrc
|
||||
self.lyrics = lyrics
|
||||
self.path_cover = path_cover
|
||||
self.url_cover = url_cover
|
||||
self.m: mutagen.MP4.MP4 | mutagen.m4a.M4A | mutagen.flac.FLAC | mutagen.mp3.MP3 = mutagen.File(self.path_file)
|
||||
|
||||
def _cover(self) -> bool:
|
||||
result = False
|
||||
data_cover = None
|
||||
|
||||
if self.url_cover:
|
||||
try:
|
||||
data_cover = requests.get(self.url_cover).content
|
||||
except:
|
||||
data_cover = ""
|
||||
elif self.path_cover:
|
||||
with open(self.path_cover, "rb") as f:
|
||||
data_cover = f.read()
|
||||
|
||||
if data_cover:
|
||||
if self.type_audio == "flac":
|
||||
flac_cover = flac.Picture()
|
||||
flac_cover.data = data_cover
|
||||
flac_cover.mime = "image/jpeg"
|
||||
|
||||
self.m.clear_pictures()
|
||||
self.m.add_picture(flac_cover)
|
||||
elif self.type_audio == "mp3":
|
||||
self.m.tags.add(APIC(encoding=3, data=data_cover))
|
||||
elif self.type_audio in ["mp4", "m4a"]:
|
||||
cover_mp4 = mp4.MP4Cover(data_cover)
|
||||
self.m.tags["covr"] = [cover_mp4]
|
||||
|
||||
result = True
|
||||
|
||||
return result
|
||||
|
||||
def save(self):
|
||||
if self.type_audio == "flac":
|
||||
self.set_flac()
|
||||
elif self.type_audio in ["mp3", "ts"]:
|
||||
self.set_mp3()
|
||||
elif self.type_audio in ["mp4", "m4a"]:
|
||||
self.set_mp4()
|
||||
|
||||
self._cover()
|
||||
self.m.save()
|
||||
|
||||
return True
|
||||
|
||||
def set_flac(self):
|
||||
if not self.m.tags:
|
||||
self.m.add_tags()
|
||||
|
||||
self.m.tags["title"] = self.title
|
||||
self.m.tags["album"] = self.album
|
||||
self.m.tags["albumartist"] = self.albumartist
|
||||
self.m.tags["artist"] = ", ".join(self.artists)
|
||||
self.m.tags["copyright"] = self.copy_right
|
||||
self.m.tags["tracknumber"] = str(self.tracknumber)
|
||||
self.m.tags["tracktotal"] = str(self.totaltrack)
|
||||
self.m.tags["discnumber"] = str(self.discnumber)
|
||||
self.m.tags["disctotal"] = str(self.totaldisc)
|
||||
self.m.tags["date"] = self.date
|
||||
self.m.tags["composer"] = ", ".join(self.composer)
|
||||
self.m.tags["isrc"] = self.isrc
|
||||
self.m.tags["lyrics"] = self.lyrics
|
||||
|
||||
def set_mp3(self):
|
||||
if not self.m.tags:
|
||||
self.m.add_tags()
|
||||
|
||||
self.m.tags.add(TIT2(encoding=3, text=self.title))
|
||||
self.m.tags.add(TALB(encoding=3, text=self.album))
|
||||
self.m.tags.add(TOPE(encoding=3, text=self.albumartist))
|
||||
self.m.tags.add(TPE1(encoding=3, text=", ".join(self.artists)))
|
||||
self.m.tags.add(TCOP(encoding=3, text=self.copy_right))
|
||||
self.m.tags.add(TRCK(encoding=3, text=str(self.tracknumber)))
|
||||
self.m.tags.add(TRCK(encoding=3, text=self.discnumber))
|
||||
self.m.tags.add(TDRC(encoding=3, text=self.date))
|
||||
self.m.tags.add(TCOM(encoding=3, text=", ".join(self.composer)))
|
||||
self.m.tags.add(TSRC(encoding=3, text=self.isrc))
|
||||
self.m.tags.add(USLT(encoding=3, lang="eng", desc="desc", text=self.lyrics))
|
||||
|
||||
def set_mp4(self):
|
||||
self.m.tags["\xa9nam"] = self.title
|
||||
self.m.tags["\xa9alb"] = self.album
|
||||
self.m.tags["aART"] = self.albumartist
|
||||
self.m.tags["\xa9ART"] = ", ".join(self.artists)
|
||||
self.m.tags["cprt"] = self.copy_right
|
||||
self.m.tags["trkn"] = [[self.tracknumber, self.totaltrack]]
|
||||
self.m.tags["disk"] = [[self.discnumber, self.totaldisc]]
|
||||
# self.m.tags['\xa9gen'] = self.genre
|
||||
self.m.tags["\xa9day"] = self.date
|
||||
self.m.tags["\xa9wrt"] = ", ".join(self.composer)
|
||||
self.m.tags["\xa9lyr"] = self.lyrics
|
||||
@@ -0,0 +1,71 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from tidal_dl_ng.constants import QualityVideo
|
||||
from dataclasses_json import dataclass_json
|
||||
from tidalapi import Quality
|
||||
|
||||
|
||||
@dataclass_json
|
||||
@dataclass
|
||||
class Settings:
|
||||
skip_existing: bool = False
|
||||
album_cover_save: bool = True
|
||||
lyrics_save: bool = False
|
||||
# TODO: Implement API KEY selection.
|
||||
api_key_index: bool = 0
|
||||
album_info_save: bool = False
|
||||
video_download: bool = True
|
||||
multi_thread: bool = False
|
||||
download_delay: bool = True
|
||||
download_base_path: str = "./download/"
|
||||
quality_audio: Quality = Quality.low_320k
|
||||
quality_video: QualityVideo = QualityVideo.P480
|
||||
use_playlist_folder: bool = True
|
||||
format_album: str = "Albums/{artist_name} - {title}/{track_num}. {artist_name} - {track_title}"
|
||||
format_playlist: str = "Playlists/{playlist_name}/{artist_name} - {track_title}"
|
||||
format_mix: str = "Mix/{mix_name}/{artist_name} - {track_title}"
|
||||
format_track: str = "Tracks/{artist_name} - {track_title}"
|
||||
format_video: str = "Videos/{artist_name} - {track_title}"
|
||||
video_convert_mp4: bool = True
|
||||
|
||||
|
||||
@dataclass_json
|
||||
@dataclass
|
||||
class HelpSettings:
|
||||
skip_existing: str = "Do not download, if file already exists."
|
||||
album_cover_save: str = "Safe cover to album folder."
|
||||
lyrics_save: str = "Safe lyrics to audio file."
|
||||
api_key_index: str = "Set the device API KEY."
|
||||
album_info_save: str = "Save album info to track?"
|
||||
video_download: str = "Allow download of videos."
|
||||
multi_thread: str = "Download several tracks in parallel."
|
||||
download_delay: str = "Activate randomized download delay to mimic human behaviour."
|
||||
download_base_path: str = "Where to store the downloaded media."
|
||||
quality_audio: str = (
|
||||
'Desired audio download quality: "LOW" (96kbps), "HIGH" (320kbps), '
|
||||
'"LOSSLESS" (16 Bit, 44,1 kHz), '
|
||||
'"HI_RES" (MQA 24 Bit, 96 kHz), "HI_RES_LOSSLESS" (up to 24 Bit, 192 kHz)'
|
||||
)
|
||||
quality_video: str = 'Desired video download quality: "360", "480", "720", "1080"'
|
||||
use_playlist_folder: str = (
|
||||
"Should items of playlist be downloaded to a separate playlist folder or to the tracks folder?"
|
||||
)
|
||||
# TODO: Describe possible variables.
|
||||
format_album: str = "Where to download albums and how to name the items."
|
||||
format_playlist: str = "Where to download playlists and how to name the items."
|
||||
format_mix: str = "Where to download mixes and how to name the items."
|
||||
format_track: str = "Where to download tracks and how to name the items."
|
||||
format_video: str = "Where to download videos and how to name the items."
|
||||
video_convert_mp4: str = (
|
||||
"Videos are downloaded as MPEG Transport Stream (TS) files. With this option each video "
|
||||
"will be converted to MP4. FFMPEG must be installed and added to your 'PATH' variable."
|
||||
)
|
||||
|
||||
|
||||
@dataclass_json
|
||||
@dataclass
|
||||
class Token:
|
||||
token_type: str | None = None
|
||||
access_token: str | None = None
|
||||
refresh_token: str | None = None
|
||||
expiry_time: float = 0.0
|
||||
@@ -0,0 +1,32 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
try:
|
||||
from PySide6 import QtCore
|
||||
|
||||
@dataclass
|
||||
class ProgressBars:
|
||||
item: QtCore.Signal
|
||||
item_name: QtCore.Signal
|
||||
list_item: QtCore.Signal
|
||||
except ModuleNotFoundError:
|
||||
class ProgressBars:
|
||||
pass
|
||||
|
||||
|
||||
# TODO: Remove if not used?
|
||||
@dataclass
|
||||
class UserList:
|
||||
name: str
|
||||
count: str
|
||||
obj: object
|
||||
|
||||
|
||||
@dataclass
|
||||
class ResultSearch:
|
||||
position: int
|
||||
artist: str
|
||||
title: str
|
||||
album: str
|
||||
duration_sec: int
|
||||
obj: object
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
@@ -0,0 +1,456 @@
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'main.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.6.1
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import QCoreApplication, QLocale, QMetaObject, QRect, QSize, Qt
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtWidgets import (
|
||||
QAbstractItemView,
|
||||
QComboBox,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QLayout,
|
||||
QLineEdit,
|
||||
QMenu,
|
||||
QMenuBar,
|
||||
QPlainTextEdit,
|
||||
QPushButton,
|
||||
QSizePolicy,
|
||||
QStatusBar,
|
||||
QTreeWidget,
|
||||
QTreeWidgetItem,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
|
||||
class Ui_MainWindow:
|
||||
def setupUi(self, MainWindow):
|
||||
if not MainWindow.objectName():
|
||||
MainWindow.setObjectName("MainWindow")
|
||||
MainWindow.resize(900, 700)
|
||||
self.a_options = QAction(MainWindow)
|
||||
self.a_options.setObjectName("a_options")
|
||||
self.a_options.setEnabled(False)
|
||||
self.a_options.setText("Options")
|
||||
self.a_options.setIconText("Options")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.a_options.setToolTip("Options")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.a_options.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.a_options.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
self.w_central = QWidget(MainWindow)
|
||||
self.w_central.setObjectName("w_central")
|
||||
self.w_central.setEnabled(True)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(100)
|
||||
sizePolicy.setVerticalStretch(100)
|
||||
sizePolicy.setHeightForWidth(self.w_central.sizePolicy().hasHeightForWidth())
|
||||
self.w_central.setSizePolicy(sizePolicy)
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.w_central.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.w_central.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.w_central.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.w_central.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.w_central.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.horizontalLayout = QHBoxLayout(self.w_central)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.lh_main = QHBoxLayout()
|
||||
self.lh_main.setObjectName("lh_main")
|
||||
self.lh_main.setSizeConstraint(QLayout.SetNoConstraint)
|
||||
self.tr_lists_user = QTreeWidget(self.w_central)
|
||||
__qtreewidgetitem = QTreeWidgetItem()
|
||||
__qtreewidgetitem.setText(1, "Info")
|
||||
__qtreewidgetitem.setText(0, "Playlist")
|
||||
self.tr_lists_user.setHeaderItem(__qtreewidgetitem)
|
||||
__qtreewidgetitem1 = QTreeWidgetItem(self.tr_lists_user)
|
||||
__qtreewidgetitem1.setFlags(Qt.ItemIsEnabled)
|
||||
__qtreewidgetitem2 = QTreeWidgetItem(self.tr_lists_user)
|
||||
__qtreewidgetitem2.setFlags(Qt.ItemIsEnabled)
|
||||
__qtreewidgetitem3 = QTreeWidgetItem(self.tr_lists_user)
|
||||
__qtreewidgetitem3.setFlags(Qt.ItemIsEnabled)
|
||||
self.tr_lists_user.setObjectName("tr_lists_user")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.tr_lists_user.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.tr_lists_user.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.tr_lists_user.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.tr_lists_user.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.tr_lists_user.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.tr_lists_user.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.tr_lists_user.setProperty("showDropIndicator", False)
|
||||
self.tr_lists_user.setIndentation(10)
|
||||
self.tr_lists_user.setUniformRowHeights(True)
|
||||
self.tr_lists_user.setSortingEnabled(True)
|
||||
self.tr_lists_user.header().setCascadingSectionResizes(True)
|
||||
self.tr_lists_user.header().setHighlightSections(True)
|
||||
self.tr_lists_user.header().setProperty("showSortIndicator", True)
|
||||
|
||||
self.lh_main.addWidget(self.tr_lists_user)
|
||||
|
||||
self.lv_search_result = QVBoxLayout()
|
||||
# ifndef Q_OS_MAC
|
||||
self.lv_search_result.setSpacing(-1)
|
||||
# endif
|
||||
self.lv_search_result.setObjectName("lv_search_result")
|
||||
self.lh_search = QHBoxLayout()
|
||||
self.lh_search.setObjectName("lh_search")
|
||||
self.l_search = QLineEdit(self.w_central)
|
||||
self.l_search.setObjectName("l_search")
|
||||
self.l_search.setAcceptDrops(False)
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.l_search.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.l_search.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.l_search.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.l_search.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.l_search.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.l_search.setLocale(QLocale(QLocale.English, QLocale.UnitedStates))
|
||||
self.l_search.setText("")
|
||||
self.l_search.setPlaceholderText("Type and press ENTER to search...")
|
||||
self.l_search.setClearButtonEnabled(True)
|
||||
|
||||
self.lh_search.addWidget(self.l_search)
|
||||
|
||||
self.cb_search_type = QComboBox(self.w_central)
|
||||
self.cb_search_type.setObjectName("cb_search_type")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.cb_search_type.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.cb_search_type.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.cb_search_type.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.cb_search_type.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.cb_search_type.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.cb_search_type.setCurrentText("")
|
||||
self.cb_search_type.setPlaceholderText("")
|
||||
|
||||
self.lh_search.addWidget(self.cb_search_type)
|
||||
|
||||
self.b_search = QPushButton(self.w_central)
|
||||
self.b_search.setObjectName("b_search")
|
||||
# if QT_CONFIG(statustip)
|
||||
self.b_search.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.b_search.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.b_search.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.b_search.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.b_search.setText("Search")
|
||||
# if QT_CONFIG(shortcut)
|
||||
self.b_search.setShortcut("")
|
||||
# endif // QT_CONFIG(shortcut)
|
||||
|
||||
self.lh_search.addWidget(self.b_search)
|
||||
|
||||
self.lv_search_result.addLayout(self.lh_search)
|
||||
|
||||
self.tr_results = QTreeWidget(self.w_central)
|
||||
self.tr_results.setObjectName("tr_results")
|
||||
self.tr_results.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.tr_results.setProperty("showDropIndicator", False)
|
||||
self.tr_results.setDragDropOverwriteMode(False)
|
||||
self.tr_results.setAlternatingRowColors(False)
|
||||
self.tr_results.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||
self.tr_results.setIndentation(10)
|
||||
self.tr_results.setSortingEnabled(True)
|
||||
self.tr_results.header().setProperty("showSortIndicator", True)
|
||||
self.tr_results.header().setStretchLastSection(False)
|
||||
|
||||
self.lv_search_result.addWidget(self.tr_results)
|
||||
|
||||
self.lh_download = QHBoxLayout()
|
||||
self.lh_download.setObjectName("lh_download")
|
||||
self.l_quality_audio = QLabel(self.w_central)
|
||||
self.l_quality_audio.setObjectName("l_quality_audio")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.l_quality_audio.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.l_quality_audio.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.l_quality_audio.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.l_quality_audio.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.l_quality_audio.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.l_quality_audio.setText("Audio")
|
||||
self.l_quality_audio.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
|
||||
|
||||
self.lh_download.addWidget(self.l_quality_audio)
|
||||
|
||||
self.cb_quality_audio = QComboBox(self.w_central)
|
||||
self.cb_quality_audio.setObjectName("cb_quality_audio")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.cb_quality_audio.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.cb_quality_audio.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.cb_quality_audio.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.cb_quality_audio.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.cb_quality_audio.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.cb_quality_audio.setCurrentText("")
|
||||
self.cb_quality_audio.setPlaceholderText("")
|
||||
self.cb_quality_audio.setFrame(True)
|
||||
|
||||
self.lh_download.addWidget(self.cb_quality_audio)
|
||||
|
||||
self.l_quality_video = QLabel(self.w_central)
|
||||
self.l_quality_video.setObjectName("l_quality_video")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.l_quality_video.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.l_quality_video.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.l_quality_video.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.l_quality_video.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.l_quality_video.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.l_quality_video.setText("Video")
|
||||
self.l_quality_video.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
|
||||
|
||||
self.lh_download.addWidget(self.l_quality_video)
|
||||
|
||||
self.cb_quality_video = QComboBox(self.w_central)
|
||||
self.cb_quality_video.setObjectName("cb_quality_video")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.cb_quality_video.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.cb_quality_video.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.cb_quality_video.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.cb_quality_video.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.cb_quality_video.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.cb_quality_video.setCurrentText("")
|
||||
self.cb_quality_video.setPlaceholderText("")
|
||||
|
||||
self.lh_download.addWidget(self.cb_quality_video)
|
||||
|
||||
self.b_download = QPushButton(self.w_central)
|
||||
self.b_download.setObjectName("b_download")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.b_download.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.b_download.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.b_download.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.b_download.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.b_download.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.b_download.setText("Download")
|
||||
# if QT_CONFIG(shortcut)
|
||||
self.b_download.setShortcut("")
|
||||
# endif // QT_CONFIG(shortcut)
|
||||
|
||||
self.lh_download.addWidget(self.b_download)
|
||||
|
||||
self.lh_download.setStretch(0, 5)
|
||||
self.lh_download.setStretch(2, 5)
|
||||
self.lh_download.setStretch(4, 15)
|
||||
|
||||
self.lv_search_result.addLayout(self.lh_download)
|
||||
|
||||
self.te_debug = QPlainTextEdit(self.w_central)
|
||||
self.te_debug.setObjectName("te_debug")
|
||||
self.te_debug.setEnabled(True)
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
|
||||
sizePolicy1.setHorizontalStretch(0)
|
||||
sizePolicy1.setVerticalStretch(0)
|
||||
sizePolicy1.setHeightForWidth(self.te_debug.sizePolicy().hasHeightForWidth())
|
||||
self.te_debug.setSizePolicy(sizePolicy1)
|
||||
self.te_debug.setMaximumSize(QSize(16777215, 16777215))
|
||||
self.te_debug.setAcceptDrops(False)
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.te_debug.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.te_debug.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.te_debug.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.te_debug.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.te_debug.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.te_debug.setUndoRedoEnabled(False)
|
||||
self.te_debug.setReadOnly(True)
|
||||
|
||||
self.lv_search_result.addWidget(self.te_debug)
|
||||
|
||||
self.lh_main.addLayout(self.lv_search_result)
|
||||
|
||||
self.lh_main.setStretch(0, 40)
|
||||
self.lh_main.setStretch(1, 60)
|
||||
|
||||
self.horizontalLayout.addLayout(self.lh_main)
|
||||
|
||||
MainWindow.setCentralWidget(self.w_central)
|
||||
self.menubar = QMenuBar(MainWindow)
|
||||
self.menubar.setObjectName("menubar")
|
||||
self.menubar.setGeometry(QRect(0, 0, 900, 24))
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.menubar.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.menubar.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.menubar.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.menubar.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.menubar.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.m_file = QMenu(self.menubar)
|
||||
self.m_file.setObjectName("m_file")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.m_file.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.m_file.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.m_file.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.m_file.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.m_file.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
MainWindow.setMenuBar(self.menubar)
|
||||
self.statusbar = QStatusBar(MainWindow)
|
||||
self.statusbar.setObjectName("statusbar")
|
||||
# if QT_CONFIG(tooltip)
|
||||
self.statusbar.setToolTip("")
|
||||
# endif // QT_CONFIG(tooltip)
|
||||
# if QT_CONFIG(statustip)
|
||||
self.statusbar.setStatusTip("")
|
||||
# endif // QT_CONFIG(statustip)
|
||||
# if QT_CONFIG(whatsthis)
|
||||
self.statusbar.setWhatsThis("")
|
||||
# endif // QT_CONFIG(whatsthis)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.statusbar.setAccessibleName("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
# if QT_CONFIG(accessibility)
|
||||
self.statusbar.setAccessibleDescription("")
|
||||
# endif // QT_CONFIG(accessibility)
|
||||
self.statusbar.setLayoutDirection(Qt.LeftToRight)
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
|
||||
self.menubar.addAction(self.m_file.menuAction())
|
||||
self.m_file.addAction(self.a_options)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
|
||||
QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", "MainWindow", None))
|
||||
___qtreewidgetitem = self.tr_lists_user.headerItem()
|
||||
___qtreewidgetitem.setText(2, QCoreApplication.translate("MainWindow", "obj", None))
|
||||
|
||||
__sortingEnabled = self.tr_lists_user.isSortingEnabled()
|
||||
self.tr_lists_user.setSortingEnabled(False)
|
||||
___qtreewidgetitem1 = self.tr_lists_user.topLevelItem(0)
|
||||
___qtreewidgetitem1.setText(0, QCoreApplication.translate("MainWindow", "Playlists", None))
|
||||
___qtreewidgetitem2 = self.tr_lists_user.topLevelItem(1)
|
||||
___qtreewidgetitem2.setText(0, QCoreApplication.translate("MainWindow", "Mixes", None))
|
||||
___qtreewidgetitem3 = self.tr_lists_user.topLevelItem(2)
|
||||
___qtreewidgetitem3.setText(0, QCoreApplication.translate("MainWindow", "Favorites", None))
|
||||
self.tr_lists_user.setSortingEnabled(__sortingEnabled)
|
||||
|
||||
___qtreewidgetitem4 = self.tr_results.headerItem()
|
||||
___qtreewidgetitem4.setText(5, QCoreApplication.translate("MainWindow", "obj", None))
|
||||
___qtreewidgetitem4.setText(4, QCoreApplication.translate("MainWindow", "Duration", None))
|
||||
___qtreewidgetitem4.setText(3, QCoreApplication.translate("MainWindow", "Album", None))
|
||||
___qtreewidgetitem4.setText(2, QCoreApplication.translate("MainWindow", "Title", None))
|
||||
___qtreewidgetitem4.setText(1, QCoreApplication.translate("MainWindow", "Artist", None))
|
||||
___qtreewidgetitem4.setText(0, QCoreApplication.translate("MainWindow", "#", None))
|
||||
self.te_debug.setPlaceholderText(QCoreApplication.translate("MainWindow", "Logs...", None))
|
||||
self.m_file.setTitle(QCoreApplication.translate("MainWindow", "File", None))
|
||||
|
||||
# retranslateUi
|
||||
@@ -0,0 +1,590 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>900</width>
|
||||
<height>700</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="w_central">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>100</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="lh_main" stretch="40,60">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetNoConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="tr_lists_user">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerHighlightSections">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Playlist</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Info</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>obj</string>
|
||||
</property>
|
||||
</column>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Playlists</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flags">
|
||||
<set>ItemIsEnabled</set>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Mixes</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flags">
|
||||
<set>ItemIsEnabled</set>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Favorites</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flags">
|
||||
<set>ItemIsEnabled</set>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="lv_search_result" stretch="0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="lh_search">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="l_search">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">Type and press ENTER to search...</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_search_type">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="b_search">
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Search</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="tr_results">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>#</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Artist</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Album</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Duration</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>obj</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="lh_download" stretch="5,0,5,0,15">
|
||||
<item>
|
||||
<widget class="QLabel" name="l_quality_audio">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Audio</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_quality_audio">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="l_quality_video">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Video</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_quality_video">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="b_download">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Download</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="te_debug">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Logs...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>900</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<widget class="QMenu" name="m_file">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="a_options"/>
|
||||
</widget>
|
||||
<addaction name="m_file"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<action name="a_options">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Options</string>
|
||||
</property>
|
||||
<property name="iconText">
|
||||
<string notr="true">Options</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true">Options</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,221 @@
|
||||
"""
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012-2014 Alexander Turkin
|
||||
Copyright (c) 2014 William Hallatt
|
||||
Copyright (c) 2015 Jacob Dawid
|
||||
Copyright (c) 2016 Luca Weiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"""
|
||||
|
||||
import math
|
||||
|
||||
from PySide6.QtCore import QRect, Qt, QTimer
|
||||
from PySide6.QtGui import QColor, QPainter
|
||||
from PySide6.QtWidgets import QWidget
|
||||
|
||||
|
||||
# Taken from https://github.com/COOLMSF/QtWaitingSpinnerForPyQt6 and adapted for PySide6.
|
||||
class QtWaitingSpinner(QWidget):
|
||||
def __init__(
|
||||
self, parent, centerOnParent=True, disableParentWhenSpinning=False, modality=Qt.WindowModality.NonModal
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
self._centerOnParent = centerOnParent
|
||||
self._disableParentWhenSpinning = disableParentWhenSpinning
|
||||
|
||||
# WAS IN initialize()
|
||||
self._color = QColor(Qt.GlobalColor.black)
|
||||
self._roundness = 100.0
|
||||
self._minimumTrailOpacity = 3.14159265358979323846
|
||||
self._trailFadePercentage = 80.0
|
||||
self._revolutionsPerSecond = 1.57079632679489661923
|
||||
self._numberOfLines = 20
|
||||
self._lineLength = 10
|
||||
self._lineWidth = 2
|
||||
self._innerRadius = 10
|
||||
self._currentCounter = 0
|
||||
self._isSpinning = False
|
||||
|
||||
self._timer = QTimer(self)
|
||||
self._timer.timeout.connect(self.rotate)
|
||||
self.updateSize()
|
||||
self.updateTimer()
|
||||
self.hide()
|
||||
# END initialize()
|
||||
|
||||
self.setWindowModality(modality)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
def paintEvent(self, QPaintEvent):
|
||||
self.updatePosition()
|
||||
painter = QPainter(self)
|
||||
painter.fillRect(self.rect(), Qt.GlobalColor.transparent)
|
||||
# Can't found in Qt6
|
||||
# painter.setRenderHint(QPainter.Antialiasing, True)
|
||||
|
||||
if self._currentCounter >= self._numberOfLines:
|
||||
self._currentCounter = 0
|
||||
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
for i in range(0, self._numberOfLines):
|
||||
painter.save()
|
||||
painter.translate(self._innerRadius + self._lineLength, self._innerRadius + self._lineLength)
|
||||
rotateAngle = float(360 * i) / float(self._numberOfLines)
|
||||
painter.rotate(rotateAngle)
|
||||
painter.translate(self._innerRadius, 0)
|
||||
distance = self.lineCountDistanceFromPrimary(i, self._currentCounter, self._numberOfLines)
|
||||
color = self.currentLineColor(
|
||||
distance, self._numberOfLines, self._trailFadePercentage, self._minimumTrailOpacity, self._color
|
||||
)
|
||||
painter.setBrush(color)
|
||||
rect = QRect(0, int(-self._lineWidth / 2), int(self._lineLength), int(self._lineWidth))
|
||||
painter.drawRoundedRect(rect, self._roundness, self._roundness, Qt.SizeMode.RelativeSize)
|
||||
painter.restore()
|
||||
|
||||
def start(self):
|
||||
self.updatePosition()
|
||||
self._isSpinning = True
|
||||
self.show()
|
||||
|
||||
if self.parentWidget and self._disableParentWhenSpinning:
|
||||
self.parentWidget().setEnabled(False)
|
||||
|
||||
if not self._timer.isActive():
|
||||
self._timer.start()
|
||||
self._currentCounter = 0
|
||||
|
||||
def stop(self):
|
||||
self._isSpinning = False
|
||||
self.hide()
|
||||
|
||||
if self.parentWidget() and self._disableParentWhenSpinning:
|
||||
self.parentWidget().setEnabled(True)
|
||||
|
||||
if self._timer.isActive():
|
||||
self._timer.stop()
|
||||
self._currentCounter = 0
|
||||
|
||||
def setNumberOfLines(self, lines):
|
||||
self._numberOfLines = lines
|
||||
self._currentCounter = 0
|
||||
self.updateTimer()
|
||||
|
||||
def setLineLength(self, length):
|
||||
self._lineLength = length
|
||||
self.updateSize()
|
||||
|
||||
def setLineWidth(self, width):
|
||||
self._lineWidth = width
|
||||
self.updateSize()
|
||||
|
||||
def setInnerRadius(self, radius):
|
||||
self._innerRadius = radius
|
||||
self.updateSize()
|
||||
|
||||
def color(self):
|
||||
return self._color
|
||||
|
||||
def roundness(self):
|
||||
return self._roundness
|
||||
|
||||
def minimumTrailOpacity(self):
|
||||
return self._minimumTrailOpacity
|
||||
|
||||
def trailFadePercentage(self):
|
||||
return self._trailFadePercentage
|
||||
|
||||
def revolutionsPersSecond(self):
|
||||
return self._revolutionsPerSecond
|
||||
|
||||
def numberOfLines(self):
|
||||
return self._numberOfLines
|
||||
|
||||
def lineLength(self):
|
||||
return self._lineLength
|
||||
|
||||
def lineWidth(self):
|
||||
return self._lineWidth
|
||||
|
||||
def innerRadius(self):
|
||||
return self._innerRadius
|
||||
|
||||
def isSpinning(self):
|
||||
return self._isSpinning
|
||||
|
||||
def setRoundness(self, roundness):
|
||||
self._roundness = max(0.0, min(100.0, roundness))
|
||||
|
||||
def setColor(self, color=Qt.GlobalColor.black):
|
||||
self._color = QColor(color)
|
||||
|
||||
def setRevolutionsPerSecond(self, revolutionsPerSecond):
|
||||
self._revolutionsPerSecond = revolutionsPerSecond
|
||||
self.updateTimer()
|
||||
|
||||
def setTrailFadePercentage(self, trail):
|
||||
self._trailFadePercentage = trail
|
||||
|
||||
def setMinimumTrailOpacity(self, minimumTrailOpacity):
|
||||
self._minimumTrailOpacity = minimumTrailOpacity
|
||||
|
||||
def rotate(self):
|
||||
self._currentCounter += 1
|
||||
if self._currentCounter >= self._numberOfLines:
|
||||
self._currentCounter = 0
|
||||
self.update()
|
||||
|
||||
def updateSize(self):
|
||||
size = int((self._innerRadius + self._lineLength) * 2)
|
||||
self.setFixedSize(size, size)
|
||||
|
||||
def updateTimer(self):
|
||||
self._timer.setInterval(int(1000 / (self._numberOfLines * self._revolutionsPerSecond)))
|
||||
|
||||
def updatePosition(self):
|
||||
if self.parentWidget() and self._centerOnParent:
|
||||
self.move(
|
||||
int(self.parentWidget().width() / 2 - self.width() / 2),
|
||||
int(self.parentWidget().height() / 2 - self.height() / 2),
|
||||
)
|
||||
|
||||
def lineCountDistanceFromPrimary(self, current, primary, totalNrOfLines):
|
||||
distance = primary - current
|
||||
if distance < 0:
|
||||
distance += totalNrOfLines
|
||||
return distance
|
||||
|
||||
def currentLineColor(self, countDistance, totalNrOfLines, trailFadePerc, minOpacity, colorinput):
|
||||
color = QColor(colorinput)
|
||||
if countDistance == 0:
|
||||
return color
|
||||
minAlphaF = minOpacity / 100.0
|
||||
distanceThreshold = int(math.ceil((totalNrOfLines - 1) * trailFadePerc / 100.0))
|
||||
if countDistance > distanceThreshold:
|
||||
color.setAlphaF(minAlphaF)
|
||||
else:
|
||||
alphaDiff = color.alphaF() - minAlphaF
|
||||
gradient = alphaDiff / float(distanceThreshold + 1)
|
||||
resultAlpha = color.alphaF() - gradient * countDistance
|
||||
# If alpha is out of bounds, clip it.
|
||||
resultAlpha = min(1.0, max(0.0, resultAlpha))
|
||||
color.setAlphaF(resultAlpha)
|
||||
return color
|
||||
@@ -0,0 +1,31 @@
|
||||
from PySide6 import QtCore
|
||||
|
||||
|
||||
# Taken from https://www.pythonguis.com/tutorials/multithreading-pyside6-applications-qthreadpool/
|
||||
class Worker(QtCore.QRunnable):
|
||||
"""
|
||||
Worker thread
|
||||
|
||||
Inherits from QRunnable to handler worker thread setup, signals and wrap-up.
|
||||
|
||||
:param callback: The function callback to run on this worker thread. Supplied args and
|
||||
kwargs will be passed through to the runner.
|
||||
:type callback: function
|
||||
:param args: Arguments to pass to the callback function
|
||||
:param kwargs: Keywords to pass to the callback function
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, fn, *args, **kwargs):
|
||||
super().__init__()
|
||||
# Store constructor arguments (re-used for processing)
|
||||
self.fn = fn
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
@QtCore.Slot() # QtCore.Slot
|
||||
def run(self):
|
||||
"""
|
||||
Initialise the runner function with passed args, kwargs.
|
||||
"""
|
||||
self.fn(*self.args, **self.kwargs)
|
||||
@@ -0,0 +1,17 @@
|
||||
[tox]
|
||||
skipsdist = true
|
||||
envlist = py310, py311, py312
|
||||
|
||||
[gh-actions]
|
||||
python =
|
||||
3.10: py310
|
||||
3.11: py311
|
||||
3.12: py312
|
||||
|
||||
[testenv]
|
||||
passenv = PYTHON_VERSION
|
||||
allowlist_externals = poetry
|
||||
commands =
|
||||
poetry install -v
|
||||
pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml
|
||||
mypy
|
||||
Reference in New Issue
Block a user