# scene tv series

Jul 23rd, 2011
195
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import re
2.
3. regular = "[\.-]?[sS](\d?\d)[\.]?[eE](\d{1,3})[\.-]?[eE]?(\d{2,3})?"
4. fov = "\.?(\d{1,2})[x](\d{2,3})([\._-](\d{1,2}[x])?)?(\d{2,3})?[\._]?"
5. retro = "\.[eE][pP](\d\d)"
6. part = "((Part|Pt|PART)[\._-]?\d{1,3})[^\d]"
7. iso8601 = ("((19|20)?\d\d)"             #year
8.            "(?P<sep>[-\.]?)"            #separator
9.            "(0[1-9]|1[012])"            #month
10.            "(?P=sep)"                   #same separator
11.            "(0[1-9]|[12][0-9]|3[01])")  #day
12. daterev = ("(0[1-9]|[12][0-9]|3[01])"
13.            "(?P<pes>[-\.])"
14.            "(0[1-9]|1[012])"
15.            "(?P=pes)"
16.            "((19|20)?\d\d)")
17. patterns = [regular, fov, retro, part, iso8601, daterev]
18.
19. fullPattern = ""
20. for pattern in patterns:
21.     sep = "(.*" if fullPattern == "" else "|(.*"
22.     fullPattern += sep + pattern + ".*)"
23. print(fullPattern)
24. # (.*[\.-]?[sS](\d?\d)[\.]?[eE](\d{1,3})[\.-]?[eE]?(\d{2,3})?.*)|(.*\.?(\d{1,2})[x](\d{2,3})([\._-](\d{1,2}[x])?)?(\d{2,3})?[\._]?.*)|(.*\.[eE][pP](\d\d).*)|(.*((Part|Pt|PART)[\._-]?\d{1,3})[^\d].*)|(.*((19|20)?\d\d)(?P<sep>[-\.]?)(0[1-9]|1[012])(?P=sep)(0[1-9]|[12][0-9]|3[01]).*)|(.*(0[1-9]|[12][0-9]|3[01])(?P<pes>[-\.])(0[1-9]|1[012])(?P=pes)((19|20)?\d\d).*)
25.
26. matches = [
27.          "Jay.Leno.2009.09.14.Jerry.Seinfeld.720p.HDTV.x264-MOMENTUM",
28.          "Jay.Leno.2009-09-14.Jerry.Seinfeld.720p.HDTV.x264-MOMENTUM",
29.          "Jay.Leno.20090914.Jerry.Seinfeld.720p.HDTV.x264-MOMENTUM",
30.          "The.7pm.Project.2010.01.03.WS.PDTV.XviD-RTA",
31.          "The.7pm.Project.2010-01-03.WS.PDTV.XviD-RTA",
32.          "The.7pm.Project.20100103.WS.PDTV.XviD-RTA",
33.          "24.S07E24.PREAIR.DVDRip.XviD-TOPAZ",
34.          "24.S7E24.PREAIR.DVDRip.XviD-TOPAZ",
35.          "24.S7E124.PREAIR.DVDRip.XviD-TOPAZ",
36.          "24.S7.E124.PREAIR.DVDRip.XviD-TOPAZ",
37.          "24.S7.E1.PREAIR.DVDRip.XviD-TOPAZ",
38.          "Friends.S10E01.UNCUT.DVDRip.XviD-SiSO"
39.          "24.1x01.12.00.AM_1.00.AM.AC3.iNTERNAL.DVDRip_WS_XviD-FoV",
40.          "Above.Suspicion.Part2.HDTV.XviD-BiA",
41.          "Above.Suspicion.Pt2.HDTV.XviD-BiA",
42.          "Above.Suspicion.Part.2.HDTV.XviD-BiA",
43.          "Above.Suspicion.Part.22.HDTV.XviD-BiA",
44.          "Above.Suspicion.Part.222.HDTV.XviD-BiA",
45.          "Above.Suspicion.Part_2.HDTV.XviD-BiA",
46.          "Archangel.2005.PART2.DVDRip.XviD-MEDiAMANiACS",
47.          "All.Dogs.Go.To.Heaven.Part1.1989.720p.BluRay.x264-HALCYON",
48.          ]
49.
50. nomatch = [
51.            "Matrix.1999.German.DL.1080p.BluRay.x264.iNTERNAL-DARM",
53.            "The.Matrix.1999.1080p.BluRay.MULTiSUBS.iNT.x264-GRiMRPR",
54.            "The.Animatrix.2003.720p.BluRay.x264-HANGOVER",
55.            "Friends.S10xE01.UNCUT.DVDRip.XviD-SiSO",
56.            "Drawing.Clipart.2000.DVDR...",
57.            "24.1X01.AC3.iNTERNAL.DVDRip_WS_XviD-FoV", # yes/no?
58.            ]
59. # should not match; false positive, sees date
60. # "24.1X01.12.00.AM_1.00.AM.AC3.iNTERNAL.DVDRip_WS_XviD-FoV",
61.
62. for rel in matches:
63.     m = re.match(fullPattern, rel)
64.     print(rel)
65.     assert m is not None
66.     print(m.groups())
67.
68. for rel in nomatch:
69.     m = re.match(fullPattern, rel)
70.     print(rel)
71.     assert m is None
72.
73. print("Done!")
74.
75. """ original one Skalman^:
76. if(preg_match("/(e[0-9][0-9])|(s[0-9][0-9])|([0-9][0-9]x[0-9][0-9])|([0-9]x[0-9][0-9])|(part[0-9])|(part\-[0-9])|(part\.[0-9])/i", strtolower(\$filename))) {
77. """
RAW Paste Data