Skip to content

Commit

Permalink
Fix error created with existing get_desc and remove dupe console
Browse files Browse the repository at this point in the history
todo: stop existing functions being called again when more screens are taken:

Auto limit screens to those returned via site description.

Stop many functions being called again when answering no to "Is this correct?"
  • Loading branch information
Audionut committed Aug 31, 2024
1 parent 6ac1fd5 commit 68c20f6
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 131 deletions.
14 changes: 7 additions & 7 deletions src/bbcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self):
pass

def clean_ptp_description(self, desc, is_disc):
console.print(f"[yellow]Cleaning PTP description...")
# console.print(f"[yellow]Cleaning PTP description...")

# Convert Bullet Points to -
desc = desc.replace("•", "-")
Expand All @@ -47,7 +47,7 @@ def clean_ptp_description(self, desc, is_disc):
desc = desc.replace('\r\n', '\n')

# Debugging print
console.print(f"[yellow]Description after unescaping HTML:\n{desc[:500]}...")
# console.print(f"[yellow]Description after unescaping HTML:\n{desc[:500]}...")

# Remove url tags with PTP/HDB links
url_tags = re.findall(r"(\[url[\=\]]https?:\/\/passthepopcorn\.m[^\]]+)([^\[]+)(\[\/url\])?", desc, flags=re.IGNORECASE)
Expand All @@ -61,7 +61,7 @@ def clean_ptp_description(self, desc, is_disc):
desc = desc.replace(url_tag, url_tag_removed)

# Debugging print
console.print(f"[yellow]Description after removing URL tags:\n{desc[:500]}...")
# console.print(f"[yellow]Description after removing URL tags:\n{desc[:500]}...")

# Remove links to PTP/HDB
desc = desc.replace('http://passthepopcorn.me', 'PTP').replace('https://passthepopcorn.me', 'PTP')
Expand All @@ -81,7 +81,7 @@ def clean_ptp_description(self, desc, is_disc):
return "", []

# Debugging print
console.print(f"[yellow]Description after removing mediainfo tags:\n{desc[:500]}...")
# console.print(f"[yellow]Description after removing mediainfo tags:\n{desc[:500]}...")

# Convert Quote tags:
desc = re.sub(r"\[quote.*?\]", "[code]", desc)
Expand Down Expand Up @@ -128,7 +128,7 @@ def clean_ptp_description(self, desc, is_disc):
comp_placeholders.append(comp)

# Debugging print
console.print(f"[yellow]Description after processing comparisons and hides:\n{desc[:500]}...")
# console.print(f"[yellow]Description after processing comparisons and hides:\n{desc[:500]}...")

# Remove Images in IMG tags:
desc = re.sub(r"\[img\][\s\S]*?\[\/img\]", "", desc, flags=re.IGNORECASE)
Expand All @@ -143,7 +143,7 @@ def clean_ptp_description(self, desc, is_disc):
desc = desc.replace(image, '')

# Debugging print
console.print(f"[yellow]Final description after removing loose images:\n{desc[:500]}...")
# console.print(f"[yellow]Final description after removing loose images:\n{desc[:500]}...")

# Re-place comparisons
for i, comp in enumerate(comp_placeholders):
Expand All @@ -164,7 +164,7 @@ def clean_ptp_description(self, desc, is_disc):
console.print(f"[yellow]Description is empty after cleaning.")
return "", imagelist

console.print(f"[green]Returning cleaned description and {len(imagelist)} images.")
# console.print(f"[green]Returning cleaned description and {len(imagelist)} images.")
return desc, imagelist

def clean_unit3d_description(self, desc, site):
Expand Down
Loading

0 comments on commit 68c20f6

Please sign in to comment.