Beispiel #1
0
def add_film():
    """
    Add a new film to the collection

    Request schema:
    {
      "name": string,
      "movie_db_id": integer
    }
    """

    # TODO: Add film to DB

    content = request.json

    # TODO: populate model with details results
    # TODO: Download poster image
    # TODO: Find director
    # TODO: Find rotten tomatoes ID
    movie_details = movie_db_client.get_movie_details(content["movie_db_id"])

    new_film = Film(content["name"], content["movie_db_id"])
    new_film.released = movie_details["release_date"]
    new_film.imdb_id = movie_details["imdb_id"]

    db.session.add(new_film)
    db.session.commit()

    return {
        "id": new_film.id,
        "name": new_film.name,
        "movie_db_id": new_film.movie_db_id,
        "released": new_film.released,
        "imdb_id": new_film.imdb_id
    }
Beispiel #2
0
    def post(self):
        naslov = self.request.get("naslov_filma")
        reziser = self.request.get("reziser")
        leto_izida = self.request.get("leto_izida")
        slika = self.request.get("slika")
        ocena = self.request.get("ocena")

        shrani = Film(naslov=naslov, reziser=reziser, leto=leto_izida, url_slike=slika, ocena=ocena)
        shrani.put()
        self.redirect_to("seznam")
Beispiel #3
0
 def create(title, author, date, type, image, synopsis, country):
     """ Create a new film """
     film = Film(title=title,
                 author=author,
                 date=date,
                 type=type,
                 image=image,
                 synopsis=synopsis,
                 country=country)
     return film.save()
Beispiel #4
0
    def create(name, year, pos, rating, url, image):
        film = Film(
            name=name,
            year=year,
            pos=pos,
            rating=rating,
            url=url,
            image=image,
        )

        return film.save()
Beispiel #5
0
 def post(self, **kwargs):
     if self.form.validate():
         film = Film(
             title = self.form.title.data,
             description = self.form.description.data,
             imdb_link=self.form.imdb_link.data,
             release_year=self.form.release_year.data,
             user = self.auth_current_user.user
         )
         film.put()
         return redirect('/films/%d' % film.key().id())
     return self.get(**kwargs)
Beispiel #6
0
    def post(self):
        ime_filma = self.request.get("ime_filma")
        ocena_filma = int(self.request.get("ocena_filma"))
        slika_filma = self.request.get("slika_filma")

        vnos_filma = Film(ime_filma=ime_filma, ocena_filma=ocena_filma, slika_filma=slika_filma)
        vnos_filma.put()

        view_vars = { "ime_filma": ime_filma,
                      "ocena_filma": ocena_filma,
                      "slika_filma": slika_filma}

        return self.render_template("vnosuspesen.html", view_vars)
Beispiel #7
0
    def post(self):
        name = self.request.get("name")
        year = int(self.request.get("year"))
        genre = self.request.get("genre")
        rating = int(self.request.get("rating"))
        image = self.request.get("image")

        film = Film(name=name,
                    year=year,
                    genre=genre,
                    rating=rating,
                    image=image)
        film.put()
        return self.redirect_to("prva")
Beispiel #8
0
 def post(self, message_id):
     shrani = Film.get_by_id(int(message_id))
     shrani.naslov = self.request.get("nov_naslov")
     shrani.reziser = self.request.get("nov_reziser")
     shrani.url_slike = self.request.get("nov_url_slike")
     shrani.ocena = self.request.get("ocena")
     shrani.put()
     return self.redirect_to("seznam")
Beispiel #9
0
    def get(self):
        vsi_filmi = Film.query().order().fetch()

        view_vars = {
            "vsi_filmi": vsi_filmi,
        }

        return self.render_template("seznamfilmov.html", view_vars)
Beispiel #10
0
 def post(self, film_id, **kwargs):
     if self.form.validate():
         film = Film.get_by_id(film_id)
         if film:
             version = FilmVersion(
                 film=film,
                 title=self.form.title.data,
                 user=self.auth_current_user.user
             )
         version.put()
     return redirect('films/%d' % film_id)
Beispiel #11
0
def extract_details1(html, url):
    tmp = {}
    film = Film()
    film.uid = int(url.split('/')[-1].split('.')[0])
    if html:
        m = re_image_url.search(html)
        if m:
            image_url = m.group(m.lastindex).replace(' ',
                                                     '').replace(';',
                                                                 ',').strip()
            image_name = image_url.split('/')[-1]
            download_image(image_url)
            film.image_name = image_name
        for regex, _key in zip(r_list, key_list):
            tmp[_key] = None
            m = regex.search(html)
            if not m:
                film._key = ''
            else:
                t = m.group(m.lastindex).replace(' ',
                                                 '').replace(';', ',').strip()
                tmp[_key] = t
        film_dict2model(film, tmp)

        urls = r_download_url.findall(html)
        field = ''
        if urls:
            for url in urls:
                field = field + url.strip()
                if urls.index(url) != len(urls) - 1:
                    field = field + ','
        film.download_url = field
    return film
Beispiel #12
0
 def createFilm(self):
     if self.is_valid():
         film = Film()
         film.title = self.cleaned_data.get("title")
         film.text = self.cleaned_data.get("about")
         film.photo = self.cleaned_data.get("photo")
         film.save()
         return False
     else:
         mistake = u"Форма заполнена с ошибками"
         return mistake
Beispiel #13
0
    def post(self):
        naslov = self.request.get("naslov")
        reziser = self.request.get("reziser")
        igralec = self.request.get("igralec")
        zanr = self.request.get("zanr")
        leto_prod = int(self.request.get("leto_prod"))
        #dropdown!
        ocena = int(self.request.get("ocena"))
        slika = self.request.get("slika")
        ogledano = bool(int(self.request.get("ogledano")))
        komentar = self.request.get("komentar")

        film = Film(naslov=naslov,
                    reziser=reziser,
                    glavni_igralec=igralec,
                    zanr=zanr,
                    leto_produkcije=leto_prod,
                    ocena=ocena,
                    slika=slika,
                    ogledano=ogledano,
                    komentar=komentar)

        film.put()
        return self.redirect_to("filmi")
Beispiel #14
0
def create_film():
    film_form = FilmForm()
    if request.method == 'POST' and film_form.validate():
        title = film_form.title.data
        desc = film_form.desc.data
        poster = film_form.poster.data
        release_date = film_form.release_date.data
        new = film_form.new.data
        film = Film(title=title,
                    desc=desc,
                    poster=poster,
                    release_date=release_date,
                    new=new)
        db.session.add(film)
        db.session.commit()
        return render_template('film.html', film=film)
    return render_template('new_film.html', form=film_form)
Beispiel #15
0
    def post(self):
        args = request.json if request.is_json else {}
        current_app.logger.debug("Input args: %s", args)

        data = Film.datatable_search(args)

        films = []
        for film in data['films']:
            film_dict = film.row2dict()
            film_dict['language'] = film.language.row2dict()
            film_dict['categories'] = [
                category.row2dict() for category in film.categories
            ]
            film_dict['actors'] = [actor.row2dict() for actor in film.actors]
            films.append(film_dict)

        response = {
            'fetch_id': args.get('fetch_id'),
            'records_total': data['records_total'],
            'records_filtered': data['records_filtered'],
            'data': films,
        }
        return response
Beispiel #16
0
 def get(self):
     all_films = Film.query().fetch()
     params = {"all_films": all_films}
     return self.render_template("vnos_filma.html", params=params)
Beispiel #17
0
def populate_film():
    print 'Archivio Film'

    with io.open(APP_ROOT + 'db_csv/films.csv', 'r',
                 encoding='utf-16') as films_file:
        films = films_file.read().split('\n')[1:]

        for film in films:

            film_spl = film.split('\t')
            if len(film_spl) > 1:

                print film_spl
                print film_spl[1]

                date = film_spl[1].split('-')
                data_a = None
                data_b = None

                if len(date) == 2:
                    date_a = int(date[0])
                    date_b = int(date[1])
                elif len(date) == 1:
                    data_a = int(date[0])

                new_el = Film(
                    titolo=film_spl[0],
                    anno_a=data_a,
                    anno_b=data_b,
                    durata=int(film_spl[3]),
                )

                #REGIA
                registi = film_spl[2].split(', ') if film_spl[2] != '' else []
                for regista in registi:
                    regista = regista.strip()
                    new_regista = Regista.query.filter_by(nome=regista).first()
                    if not new_regista:
                        new_regista = Regista(nome=regista)
                        db.session.add(new_regista)
                        #db.session.commit()

                    new_el.regia.append(new_regista)

                #AUDIO
                audii = film_spl[5].split('/') if film_spl[5] != '' else []
                for audio in audii:
                    audio = audio.strip()
                    new_audio = Audio.query.filter_by(nome=audio).first()
                    if not new_audio:
                        new_audio = Audio(nome=audio)
                        db.session.add(new_audio)
                        #db.session.commit()

                    new_el.audio.append(new_audio)

                #SUB
                subs = film_spl[4].split('/') if film_spl[4] != '' else []
                for sub in subs:
                    sub = sub.strip()
                    new_sub = Audio.query.filter_by(nome=sub).first()
                    if not new_sub:
                        new_sub = Audio(nome=sub)
                        db.session.add(new_sub)
                        #db.session.commit()

                    new_el.sub.append(new_sub)

                db.session.add(new_el)

    db.session.commit()

    print User.query.all()
Beispiel #18
0
 def get(self):
     seznam = Film.query().fetch()
     params = {"seznam": seznam}
     return self.render_template("base.html", params=params)
Beispiel #19
0
 def post(self, film_id):
     zapis = Film.get_by_id(int(film_id))
     zapis.izbrisano = False
     zapis.put()
     return self.redirect_to("skriti_seznam")
Beispiel #20
0
 def get(self, film_id):
     zapis = Film.get_by_id(int(film_id))
     params = {"zapis": zapis}
     return self.render_template("obnovi.html", params=params)
Beispiel #21
0
 def get(self):
     seznam = Film.query(Film.izbrisano == True).fetch()
     params = {"seznam": seznam}
     return self.render_template("skriti_seznam.html", params=params)
Beispiel #22
0
 def post(self, message_id):
     shrani = Film.get_by_id(int(message_id))
     shrani.izbrisano = True
     shrani.put()
     return self.redirect_to("seznam")
Beispiel #23
0
    def get(self, message_id):
        shrani = Film.get_by_id(int(message_id))

        params = {"shrani": shrani}
        return self.render_template("seznam_skrij.html", params=params)
Beispiel #24
0
def extract_details(html, url):
    film = Film()
    film.uid = int(url.split('/')[-1].split('.')[0])
    if html:
        m = re_image_url.search(html)
        if m:
            image_url = m.group(m.lastindex).replace(' ',
                                                     '').replace(';',
                                                                 ',').strip()
            image_name = image_url.split('/')[-1]
            download_image(image_url)
            film.image_name = image_name

        m = r_name_cn.search(html)
        if not m:
            film.name_cn = ''
        else:
            film.name_cn = m.group(m.lastindex).replace(' ', '').replace(
                ';', ',').strip()

        m = r_name.search(html)
        if not m:
            film.name = ''
        else:
            film.name = m.group(m.lastindex).replace(' ',
                                                     '').replace(';',
                                                                 ',').strip()

        m = r_year.search(html)
        if not m:
            film.year = ''
        else:
            film.year = m.group(m.lastindex).replace(' ',
                                                     '').replace(';',
                                                                 ',').strip()

        m = r_country.search(html)
        if not m:
            film.country = ''
        else:
            film.country = m.group(m.lastindex).replace(' ', '').replace(
                ';', ',').strip()

        m = r_category.search(html)
        if not m:
            film.category = ''
        else:
            film.category = m.group(m.lastindex).replace(' ', '').replace(
                ';', ',').strip()

        m = r_language.search(html)
        if not m:
            film.language = ''
        else:
            film.language = m.group(m.lastindex).replace(' ', '').replace(
                ';', ',').strip()

        m = r_subtitle.search(html)
        if not m:
            film.subtitle = ''
        else:
            film.subtitle = m.group(m.lastindex).replace(' ', '').replace(
                ';', ',').strip()

        m = r_release_date.search(html)
        if not m:
            film.release_date = ''
        else:
            film.release_date = m.group(m.lastindex).replace(
                ' ', '').replace(';', ',').strip()

        m = r_score.search(html)
        if not m:
            film.score = ''
        else:
            film.score = m.group(m.lastindex).replace(' ',
                                                      '').replace(';',
                                                                  ',').strip()

        m = r_file_size.search(html)
        if not m:
            film.file_size = ''
        else:
            film.file_size = m.group(m.lastindex).replace(
                ' ', '').replace(';', ',').strip()

        m = r_movie_duration.search(html)
        if not m:
            film.movie_duration = ''
        else:
            film.movie_duration = m.group(m.lastindex).replace(
                ' ', '').replace(';', ',').strip()

        m = r_director.search(html)
        if not m:
            film.director = ''
        else:
            film.director = m.group(m.lastindex).replace(' ', '').replace(
                ';', ',').strip()

        urls = r_download_url.findall(html)
        field = ''
        if urls:
            for url in urls:
                field = field + url.strip()
                if urls.index(url) != len(urls) - 1:
                    field = field + ','
        # print field
        film.download_url = field
    return film
Beispiel #25
0
 def post(self, film_id):
     zapis = Film.get_by_id(int(film_id))
     zapis.key.delete()
     return self.redirect_to("skriti_seznam")
Beispiel #26
0
 def create(title, date, author):
     """ Create a new film """
     film = Film(title=title, date=date, author=author)
     return film.save()
Beispiel #27
0
#Import our configuration functions
from models import Film
from config import get_session

#Get instances for working with DB
session = get_session()

#***********************Working with db********************
print("Working with table: ", Film.__name__)
'''
films = session.query(Film).session.query(Film)
#Simple query 
for film in films:  
    print("for", film.title)

#Using query.filter_by
q = session.query(Film).filter_by(year = '2018')
film = q.first()
print("filter_by", film)

#Using SQL
q = session.execute("SELECT * FROM film")
film = q.first()
print("SQL", film)
'''
# User is the name of table that has a column name
s = Film.select().where(Film.c.id>2)
result = session.execute(s)

for row in result:
   print (row)
Beispiel #28
0
#Import our configuration functions
from models import Film
from config import get_session

#Get instances for working with DB
session = get_session()

#***********************Working with db********************
films = [Film(title="Doctor Junior", director="Mikle Johns", year="2018"), Film(title="Doctor Strange", director="Scott Derrickson", year="2016")]
session.add(films[0])
session.add(films[1])
# or session.add_all(films)
session.commit()
Beispiel #29
0
    def create(title, date):
        """ Create a new film """
        film = Film(title=title, date=date)

        return film.save()