Пример #1
0
    def get_cartelera_cines_de_cadena(self):

        theaters = []

        t_theaters = self.get_cines_cadena()

        for t in t_theaters:

            theater_name, url = t

            theater = Theater(name = theater_name.capitalize())
            theater.movies = self.get_programacion_cine(url=url)
            theaters.append(theater)

        return theaters
Пример #2
0
    def get_cartelera_cines_de_cadena(self):
        """
            Returns a list of Theater objects.
        """
        result = []

        for t in self.get_cines_cadena():
            cine, idCine, urlCine = t
            
            theater = Theater(name=cine)

            if idCine == 0:
                theater.movies  = self.get_programacion_cine(url=urlCine)
            else:
                theater.movies = self.get_programacion_cine(idCine=idCine)
                
            # print "Theaters for %s: %s" % (self.tag, theater)

            result.append(theater)

        return result
Пример #3
0
        def get_movies(url):

            retries = 3
            result = []
            while retries > 0:
                try:    
                    r = self.conn.request(
                        'GET', 
                        url,
                        headers = urllib3.make_headers(user_agent=wanderer())
                    )
                    break
                except TimeoutError:
                    retries = retries - 1  


            if retries > 0:
                if r.status == 200:
                    # Page readed ok
                    html = r.data.decode(self.encoding, errors='replace')            
                    soup = BeautifulSoup(html)

                    theater_names = [t.string for t in soup.find_all(
                        'span', class_='TitulosBlanco'
                    )]

                    theater_codes = [ t['id'][4:] for t in soup.find_all(
                        'a', id=re.compile('^Cine*')
                    )]


                    
                    for i in range(0, len(theater_names)):

                        theater = Theater(name=theater_names[i])
                        movies = []

                        tmp = soup.find_all('a', id=re.compile(
                            '^idPelCine.+' + theater_codes[i]
                        ))
                        
                        for p in tmp:
                            movie_name = p.parent.find('a', class_='peliculaCartelera').string
                            movie_showtimes = [t.string for t in p.parent.parent.find_all(
                                'span', class_=re.compile('^horariosCartelera*')
                            )]

                            movie_showtimes = self.grab_horarios(" ".join(movie_showtimes))


                            movie = Movie(
                                name = self.purify_movie_name(movie_name),
                                showtimes = movie_showtimes,
                                isSubtitled = self.is_movie_subtitled(movie_name),
                                isTranslated = self.is_movie_translated(movie_name),
                                isHD = self.is_movie_HD(movie_name),
                                is3D = self.is_movie_3D(movie_name),
                                isDbox = self.is_movie_dbox(movie_name),
                            )

                            movies.append(movie)
                            # movies.sort(key=lambda x: x.name)

                        theater.movies = movies

                        result.append(theater)
                else:
                    return []
            else:
                return []

            return result
Пример #4
0
from models import Admin
from models import Hospital, Ward, Theater
from models import PractitionerDetails, PatientDetails
from models import PreOperativeRecord, OperativeRecord, PostOperativeRecord
from models import OperationRecord
from models import db_session as db

# creating models for use
admin = Admin(username="******", email="*****@*****.**", password="******")
parirenyatwa = Hospital(name="parirenyatwa")
bc1 = Ward(name="BC1", hospital_id=parirenyatwa.id)
theatre_a = Theater(name="TA", ward_id=bc1.id)

if __name__ == '__main__':
    db.add_all([admin, parirenyatwa, bc1, theatre_a])
    db.commit()