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

[Fix]#921 #925 Manual scrapping integration fixed. #924

Open
wants to merge 3 commits into
base: manual_scrape
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Default PUID and PGID to 1000 if not set
PUID=${PUID:-1000}
PGID=${PGID:-1000}
PORT=${PORT:-8080}

echo "Starting Container with $PUID:$PGID permissions..."

Expand Down Expand Up @@ -77,15 +78,15 @@ echo "Container Initialization complete."
echo "Starting Riven (Backend)..."
if [ "$PUID" = "0" ]; then
if [ "${DEBUG}" != "" ]; then # check if DEBUG is set to a truthy value
cd /riven/src && poetry add debugpy && poetry run python3 -m debugpy --listen 0.0.0.0:5678 main.py
cd /riven/src && poetry add debugpy && poetry run python3 -m debugpy --listen 0.0.0.0:5678 main.py --port $PORT
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
else
cd /riven/src && poetry run python3 main.py
cd /riven/src && poetry run python3 main.py --port $PORT
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
fi
else
if [ "${DEBUG}" != "" ]; then # check if DEBUG is set to a truthy value
poetry add debugpy
exec su -m $USERNAME -c "cd /riven/src && poetry run python3 -m debugpy --listen 0.0.0.0:5678 main.py"
exec su -m $USERNAME -c "cd /riven/src && poetry run python3 -m debugpy --listen 0.0.0.0:5678 main.py --port $PORT"
else
su -m "$USERNAME" -c "cd /riven/src && poetry run python3 main.py"
su -m "$USERNAME" -c "cd /riven/src && poetry run python3 main.py --port $PORT"
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
fi
fi
14 changes: 14 additions & 0 deletions src/program/services/scrapers/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,25 @@ def _parse_results(item: MediaItem, results: Dict[str, str], log_msg: bool = Tru
# Ex: [2018, 2019, 2020] for a 2019 movie
if _check_item_year(item, torrent.data):
torrents.add(torrent)
else:
logger.debug(f"Ignoring torrent {torrent.infohash}:{raw_title} due to not in time year range, {item.log_string}")

elif item.type == "show":
if torrent.data.seasons and not torrent.data.episodes:
# We subtract one because Trakt doesn't always index
# shows according to uploaders
if len(torrent.data.seasons) >= (len(needed_seasons) - 1):
torrents.add(torrent)
else:
logger.debug(f"Ignoring torrent {torrent.infohash}:{raw_title} due mismatch in season size, required {len(needed_seasons)} current {len(torrent.data.seasons)}, {item.log_string}")

elif item.type == "season":
# If the torrent has the needed seasons and no episodes, we can add it
if any(season in torrent.data.seasons for season in needed_seasons) and not torrent.data.episodes:
torrents.add(torrent)
else:
logger.debug(f"Ignoring torrent {torrent.infohash}:{raw_title} due to missing required season, {item.log_string}")


elif item.type == "episode":
# If the torrent has the season and episode numbers, we can add it
Expand All @@ -117,17 +124,23 @@ def _parse_results(item: MediaItem, results: Dict[str, str], log_msg: bool = Tru
for season in needed_seasons
) and not torrent.data.episodes:
torrents.add(torrent)
else:
logger.debug(f"Ignoring torrent {torrent.infohash}:{raw_title} due to mismatch in season and episode numbers, {item.log_string}")

else:
logger.debug(f"Skipping torrent {infohash}:{raw_title} as it does not fit to any category. {item.log_string}")
processed_infohashes.add(infohash)

except (ValueError, AttributeError) as e:
logger.debug(f"Invalid torrent {raw_title} : {e}")
# The only stuff I've seen that show up here is titles with a date.
# Dates can be sometimes parsed incorrectly by Arrow library,
# so we'll just ignore them.
if settings_manager.settings.scraping.parse_debug and log_msg:
logger.debug(f"Skipping torrent: '{raw_title}' - {e}")
continue
except GarbageTorrent as e:
logger.debug(f"GarbageTorrent {raw_title} due to {e}")
if settings_manager.settings.scraping.parse_debug and log_msg:
logger.debug(e)
continue
Expand All @@ -140,6 +153,7 @@ def _parse_results(item: MediaItem, results: Dict[str, str], log_msg: bool = Tru
torrents_dict[torrent.infohash] = Stream(torrent)
logger.log("SCRAPER", f"Kept {len(torrents_dict)} streams for {item.log_string} after processing bucket limit")
return torrents_dict
logger.debug(f"No valid torrent remains after filtering for {item.log_string}")
return {}


Expand Down