Skip to content

Commit

Permalink
Fix regex
Browse files Browse the repository at this point in the history
it still happened to work, but this is more proper
  • Loading branch information
HarHarLinks authored Jul 26, 2023
1 parent d65ad09 commit 255da46
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions socialmediadownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:
for suffix in ["enabled", "info", "image", "video", "thumbnail"]:
helper.copy(f"{prefix}.{suffix}")

reddit_pattern = re.compile(r"^((?:https?:)?\/\/)?((?:www|m)\.)?((?:reddit\.com|redd.it))(\/r\/.*\/comments\/.*)(\/)?$")
instagram_pattern = re.compile(r"/(?:https?:\/\/)?(?:www.)?instagram.com\/?([a-zA-Z0-9\.\_\-]+)?\/([p]+)?([reel]+)?([tv]+)?([stories]+)?\/([a-zA-Z0-9\-\_\.]+)\/?([0-9]+)?/")
youtube_pattern = re.compile(r"^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$")
reddit_pattern = re.compile(r"^((?:https?:)?\/\/)?((?:www|m)\.)?((?:reddit\.com|redd\.it))(\/r\/.*\/comments\/.*)(\/)?$")
instagram_pattern = re.compile(r"^(?:https?:\/\/)?(?:www\.)?instagram\.com\/?([a-zA-Z0-9\.\_\-]+)?\/([p]+)?([reel]+)?([tv]+)?([stories]+)?\/([a-zA-Z0-9\-\_\.]+)\/?([0-9]+)?/$")
youtube_pattern = re.compile(r"^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu\.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$")

class SocialMediaDownloadPlugin(Plugin):
async def start(self) -> None:
Expand Down Expand Up @@ -186,4 +186,4 @@ async def handle_reddit(self, evt, url_tup):

elif self.config["reddit.image"] or self.config["reddit.video"]:
self.log.warning(f"Unknown media type {query_url}: {mime_type}")
return
return

0 comments on commit 255da46

Please sign in to comment.