[kwlug-disc] Regular Expression to Match Movie Titles and Year and Ignore the rest.
Andres Vargas
zodman at gmail.com
Fri Jan 3 14:47:57 EST 2025
dont overthink.
https://pypi.org/project/guessit/
$ guessit "Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi"
For: Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi
GuessIt found: {
"title": "Treme",
"season": 1,
"episode": 3,
"episode_title": "Right Place, Wrong Time",
"source": "HDTV",
"video_codec": "Xvid",
"release_group": "NoTV",
"container": "avi",
"mimetype": "video/x-msvideo",
"type": "episode"
}
On Thu, Jan 2, 2025 at 2:02 AM William Park via kwlug-disc <
kwlug-disc at kwlug.org> wrote:
> Second method is easier.
>
> echo "Zero.Dark.Thirty.2012.720p.BrRip.x264.BOKUTOX.YIFY.mp4" | while IFS=.
> read -a x; do
> y=
> skip=0
> for i in "${x[@]}"; do
> case $i in
> 201[0-9]) y+=" ($i)" ;;
> [0-9]*p) y+="-$i" ; skip=1 ;;
> mp4) y+=".$i" ;;
> *) if [[ skip -eq 0 ]]; then y+="${y:+ }$i"; fi ;;
> esac
> done
> echo "y={$y}"
> done
>
> --
>
> On 2025-01-01 03:52, William Park via kwlug-disc wrote:
>
> From the top of my head,
> - cut the string on ".2012.720p."
> - change "Zero.Dark.Thirty" to "Zero Dark Thirty "
> - change ".2012.720p." to "(2012-720p)"
> - change "BrRip.x264.BOKUTOX.YIFY.mp4" to ".mp4"
>
> Or,
> - cut the string on "." (period)
> - loop through the substrings, and search for "2012" and/or "720p"
> - reassemble parts
> --
> William
>
>
> On 2024-12-31 11:22, John Driezen wrote:
>
> Can anyone give me a regular expression to turn the following filename
>
> "Zero.Dark.Thirty.2012.720p.BrRip.x264.BOKUTOX.YIFY.mp4"
>
> into
>
> "Zero Dark Thirty (2012)-720p.mp4"
>
> 201[0-9] matches the year
>
> How do I match the title before the year, and ignore everything after the
> ".720p"?
>
> John Driezen
>
>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.
>
>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or emailkwlug-disc-owner at kwlug.org to contact a human being.
>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20250103/1f5c15eb/attachment.htm>
More information about the kwlug-disc
mailing list