"""
import time, datetime
+import locale
import re
+import BeautifulSoup
import os
import sys
import urllib
now = datetime.datetime(*time.localtime(timestamp)[:7])
return now
+def parse_date(s, french=True):
+ """Essaye d'obtenir une date à partir du string fourni"""
+ s = s.lower()
+ if isinstance(s, unicode):
+ s = s.encode("utf-8")
+ if s.startswith("le "):
+ s = s[3:]
+ # Y U PARKINSON ?
+ s = re.sub(" +", " ", s)
+ # Pour avoir les noms de dates en Français
+ if french:
+ locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
+ for format in ["%d %B %Y"]:
+ try:
+ struct = time.strptime(s, format)
+ return datetime.datetime(*struct[:7])
+ except ValueError:
+ pass
+ raise ValueError("%r : Didn't manage to convert as date, sorry." % (s,))
+
def last_dtc():
"""Vérifie si il y a des quotes DTC non lues"""
return dtc.last_inserted()
nepisodes = len(episodes)
return nsaisons * 100 + nepisodes
+def last_noob_warpzone():
+ p = urllib.urlopen("http://noob-tv.com/agenda01.html")
+ t = p.read()
+ # On parse
+ soup = BeautifulSoup.BeautifulSoup(t)
+ # On récupère tous les évènements
+ garbage = soup.findAll("strong")
+ events = []
+ for o in garbage:
+ l = o.findAll("span", attrs={"class":"Style31"})
+ if l:
+ events.append([o.text[:o.text.index(":")].strip(), l[0].string.lower().strip()]) # la date, l'event
+ # On garde que les "sorties"
+ events = [o for o in events if "sortie" in o[1]]
+ # Fucking HTML
+ events = [[o[0].replace(u"û", u"û").replace(u"é", u"é"), o[1]] for o in events]
+ # Parsing des dates
+ eventss = []
+ for i in range(len(events)):
+ raw_date, event = events[i]
+ try:
+ eventss.append([parse_date(raw_date), event])
+ except ValueError:
+ pass
+ events = eventss
+ del eventss
+ noobs = [ev for ev in events if "noob" in ev[1]]
+ warpzones = [ev for ev in events if "warpzone" in ev[1]]
+ # On prend en considération le dernier évènement qui a eu lieu
+ now = get_now()
+ ######
+ ###### RHÂ, shit, y'a des fuckings trucs du genre "1er" dans les dates… :/
+ return noobs, warpzones
+
def get_file():
"""Récupère la liste des derniers ids de chaque truc, stockée dans le fichiers."""
f = open(store_published_file)