Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash script for linux #124

Open
msebastian100 opened this issue Jul 30, 2024 · 2 comments
Open

bash script for linux #124

msebastian100 opened this issue Jul 30, 2024 · 2 comments

Comments

@msebastian100
Copy link

msebastian100 commented Jul 30, 2024

Hello,
I have created a bash script for linux but although the commands are correct I can't get a login.

The command would be correct and works under windows. unfortunately not under linux

audiobook-dl --username "[email protected]" --password "xxxxxxxxxxxx" https://www.storytel.com/de/books/der-sturm-vernichtet-engelhardt-krieger-ermitteln-band-6-ungek%C3%BCrzte-lesung-8823385

linux script
create with nano audiobookdl.sh
then chmod +x audiobookdl.sh
then ./audiobookdl.sh

Supported for now: storytel

Debug log linux:

Running audiobook-dl command...
DEBUG audiobook-dl 0.7.3
DEBUG python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]
INFO Finding compatible source
INFO Authenticating with storytel
DEBUG Logging in
ERROR: User not authorized

Make sure you have given the correct cookies with the --cookie
argument or with --username and --password, and
have all the right permissions to access the book you are trying to download.

Traceback
Traceback (most recent call last):
File "/root/venv/lib/python3.10/site-packages/audiobookdl/main.py", line 31, in main
process_url(url, options, config)
File "/root/venv/lib/python3.10/site-packages/audiobookdl/main.py", line 51, in process_url
authenticate(url, source, options, config)
File "/root/venv/lib/python3.10/site-packages/audiobookdl/main.py", line 134, in authenticate
login(url, source, options, config)
File "/root/venv/lib/python3.10/site-packages/audiobookdl/main.py", line 115, in login
source.login(url, **login_data)
File "/root/venv/lib/python3.10/site-packages/audiobookdl/sources/source/init.py", line 86, in login
self._login(url, **kwargs)
File "/root/venv/lib/python3.10/site-packages/audiobookdl/sources/storytel.py", line 53, in _login
raise UserNotAuthorized
audiobookdl.exceptions.UserNotAuthorized

bash Script;

#!/bin/bash

# Exit script on any error
set -e

# Logfile setup
LOGFILE="audiobook_dl_installation.log"
exec &> >(tee -a "$LOGFILE")

echo "Logfile: $LOGFILE"

# Update package lists
echo "Updating package lists..."
sudo apt update

# Function to check if a package is installed
is_installed() {
    dpkg -l | grep -qw "$1"
}

# Check and install system packages
packages_installed=true

echo "Checking and installing system packages..."

if ! is_installed python3; then
    echo "Installing Python3..."
    sudo apt install -y python3
    packages_installed=false
fi

if ! is_installed python3-pip; then
    echo "Installing python3-pip..."
    sudo apt install -y python3-pip
    packages_installed=false
fi

if ! is_installed python3-venv; then
    echo "Installing python3-venv..."
    sudo apt install -y python3-venv
    packages_installed=false
fi

if [ "$packages_installed" = true ]; then
    echo "System dependencies already installed."
else
    echo "System dependencies installed."
fi

# Create virtual environment if not already existing
if [ ! -d "venv" ]; then
    echo "Creating virtual environment..."
    python3 -m venv venv
else
    echo "Virtual environment already exists."
fi

# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate

# Upgrade pip in the virtual environment
echo "Upgrading pip..."
pip install --upgrade pip > /dev/null 2>&1

# Function to check if a Python package is installed in the virtual environment
pip_installed() {
    pip show "$1" &> /dev/null
}

# List of required Python packages
required_packages=(appdirs attrs cssselect importlib-resources lxml m3u8 mutagen pillow pycountry pycryptodome requests rich tomli urllib3)

# Check and install required Python packages
all_packages_installed=true

echo "Checking and installing Python packages..."

for package in "${required_packages[@]}"; do
    if ! pip_installed "$package"; then
        echo "Installing $package..."
        pip install "$package" > /dev/null 2>&1
        all_packages_installed=false
    fi
done

# Check and install audiobook-dl
if ! pip_installed audiobook-dl; then
    echo "Installing audiobook-dl..."
    pip install audiobook-dl > /dev/null 2>&1
    all_packages_installed=false
fi

if [ "$all_packages_installed" = true ]; then
    echo "Python dependencies and audiobook-dl already installed."
else
    echo "Python dependencies and audiobook-dl installed."
fi

# Prompt for username, password, and URL
read -p "Enter your username: " USERNAME
read -p "Enter your password (will be shown in cleartext): " PASSWORD
read -p "Enter the URL: " URL

# Log the username and URL
echo "Username: $USERNAME" >> "$LOGFILE"
echo "URL: $URL" >> "$LOGFILE"

# Run audiobook-dl command
echo "Running audiobook-dl command..."
audiobook-dl --username "$USERNAME" --password "$PASSWORD" "$URL"

echo "Script completed successfully."

greetings msebastian100

@freddy36
Copy link
Collaborator

Is this still a problem with the latest version (v0.7.5?

@msebastian100
Copy link
Author

msebastian100 commented Dec 31, 2024

not sure as the old version is always installed with the command.
pip install audiobook-dl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants