diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4b83116 --- /dev/null +++ b/install.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# Journey FM Playlist Creator - Linux Installer + +echo "Journey FM Playlist Creator - Linux Installer" +echo "==============================================" + +# Get the directory where this script is located +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +echo "Installing in: $DIR" + +# Check if Python 3 is installed +if ! command -v python3 > /dev/null 2>&1; then + echo "Python 3 not found. Installing Python 3..." + sudo apt update && sudo apt install -y python3 python3-pip python3-venv +fi + +# Create virtual environment +echo "Creating virtual environment..." +python3 -m venv "$DIR/.venv" + +# Activate virtual environment +source "$DIR/.venv/bin/activate" + +# Install Python dependencies +echo "Installing Python dependencies..." +pip install -r "$DIR/requirements.txt" + +# Install Chromium browser +if ! command -v chromium-browser > /dev/null 2>&1; then + echo "Installing Chromium browser..." + sudo apt update && sudo apt install -y chromium-browser +fi + +# Create application icon +echo "Creating application icon..." +python3 "$DIR/create_icon.py" + +# Create desktop entry +echo "Creating desktop entry..." +mkdir -p ~/.local/share/applications + +cat > ~/.local/share/applications/journey-fm.desktop << EOF +[Desktop Entry] +Name=Journey FM Playlist +Exec=$DIR/journey_fm_app.sh +Icon=$DIR/icon.png +Type=Application +Categories=Utility; +EOF + +chmod +x ~/.local/share/applications/journey-fm.desktop + +# Update desktop database +echo "Updating desktop database..." +update-desktop-database ~/.local/share/applications + +# Make scripts executable +chmod +x "$DIR/journey_fm_app.sh" + +echo "Installation complete!" +echo "You can now find 'Journey FM Playlist' in your applications menu." +echo "Or run: $DIR/journey_fm_app.sh" \ No newline at end of file diff --git a/journey_fm_app.sh b/journey_fm_app.sh old mode 100644 new mode 100755 index 8628070..b86494a --- a/journey_fm_app.sh +++ b/journey_fm_app.sh @@ -4,11 +4,23 @@ # Get the directory where this script is located DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -# Activate virtual environment if it exists -if [ -d "$DIR/.venv" ]; then - source "$DIR/.venv/bin/activate" +# Create virtual environment if it doesn't exist +if [ ! -d "$DIR/.venv" ]; then + python3 -m venv "$DIR/.venv" +fi + +# Activate virtual environment +source "$DIR/.venv/bin/activate" + +# Install dependencies +pip install -r "$DIR/requirements.txt" + +# Check if Chromium is installed, install if not +if ! command -v chromium-browser > /dev/null 2>&1; then + echo "Chromium not found. Installing Chromium..." + sudo apt update && sudo apt install -y chromium-browser fi # Run the application cd "$DIR" -python journey_fm_app.py \ No newline at end of file +python3 journey_fm_app.py \ No newline at end of file diff --git a/main.py b/main.py index 39e61fa..98848d9 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,7 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager +from selenium.webdriver.common.by import By from bs4 import BeautifulSoup import os from plexapi.myplex import MyPlexAccount @@ -33,7 +34,12 @@ def scrape_recently_played(): options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") options.add_argument("--disable-gpu") - service = Service(ChromeDriverManager().install()) + options.add_argument("--remote-debugging-port=9222") + options.add_argument("--user-data-dir=/tmp/chromium") + options.add_argument("--no-first-run") + options.add_argument("--disable-extensions") + options.binary_location = "/usr/bin/chromium-browser" + service = Service() driver = webdriver.Chrome(service=service, options=options) url = 'https://www.myjourneyfm.com/recently-played/'