ineeee / Taigabot

taiga irc bot
GNU General Public License v3.0
4 stars 7 forks source link

[youtube] Add shorts regex #38

Closed 676339784 closed 2 years ago

676339784 commented 2 years ago

Right now, the regex doesn't support a non-https link (e.g. www.youtube.com/shorts/P36xIAHDL6w won't match)

ineeee commented 2 years ago

hi u asked me to look at this so. to improve your regex u can:

remove redundant groups

escape dots and slashes

avoid .*

after removing capturing groups that aren't being used, the index in the following line has changed:

https://github.com/inexist3nce/Taigabot/blob/b00b4c23f5a6b756fc9cd6a2d1a15a8024efa779/plugins/youtube.py#L212

additionally, please refrain from using multi-line regexes (as in regex code that spans multiple lines, not regex that matches multiple lines) because taigabot prints all available plugins to the terminal, and multi-line regexes breaks the output making it look ugly (looking at u prushy https://github.com/inexist3nce/Taigabot/commit/f2a1d5dbd2b0985b57d314f9c24d9834880ad64a)

ineeee commented 2 years ago

i checked it (using my browser's regex engine) https?:\/\/(www\.)?youtube\.com\/shorts\/([a-zA-Z0-9_]+):

the capturing group with the id is 2.