def startElement(self, name, attrs): if not name in self.inElement: if not self.ignore_missing_tags: print "Error: Unknown Artist element '%s'." % name sys.exit() elif not name in self.unknown_tags: self.unknown_tags.append(name) self.inElement[name] = True if name == 'artist': self.artist = model.Artist()
def getArtistDetails(self, artist_id): ''' function get detail of artist with id input if id invalid return None ''' try: dic = self.database.child('music-player/artists').child( artist_id).get().val() artist = model.Artist(artist_id, dic["name"], dic["cover"], dic["profile"]) return artist except: return None
def artist_create(): form = ArtistUpdateForm() if form.validate_on_submit(): artist_db = model.Artist() form.populate_obj(artist_db) artist_db.put() return flask.redirect('/artist/%i' % artist_db.key.id()) return flask.render_template( 'artist/artist_update.html', html_class='artist-create', title='Create Artist', form=form, )
def detect(self, path): ''' FILE EXAMPLE: Name of artist C:\Image\Artist.png <-- Second line: Image cover local path Multiline after <-- Profile of Artist (Same as: Name, age, address, ...) ''' artist = model.Artist() artist.aid = utils.generateID() with open(path) as data: artist.name = data.readline() artist.cover = data.readline() artist.profile = data.readlines() return artist
def startElement(self, name, attrs): if name not in self.inElement: if not self.ignore_missing_tags: print("Error: Unknown Artist element '%s'." % name) sys.exit() elif name not in self.unknown_tags: self.unknown_tags.append(name) self.inElement[name] = True if name == "artist": self.artist = model.Artist() elif name == "image": image = model.ImageInfo() for f in ("height", "type", "uri", "uri150", "width"): setattr(image, f, attrs[f]) self.artist.images.append(image) if len(attrs) != 5: print("ATTR ERROR") print(attrs) sys.exit()
def startElement(self, name, attrs): if not name in self.inElement: if not self.ignore_missing_tags: print "Error: Unknown Artist element '%s'." % name sys.exit() elif not name in self.unknown_tags: self.unknown_tags.append(name) self.inElement[name] = True if name == "artist": self.artist = model.Artist() elif name == "image": image = model.ImageInfo() image.height = attrs["height"] image.imageType = attrs["type"] image.uri = attrs["uri"] image.uri150 = attrs["uri150"] image.width = attrs["width"] self.artist.images.append(image) if len(attrs) != 5: print "ATTR ERROR" print attrs sys.exit()
def __init__(self, exporter, stop_after=0, ignore_missing_tags=False): self.artist = model.Artist() self.exporter = exporter self.stop_after = stop_after self.ignore_missing_tags = ignore_missing_tags
with open('data/songs.csv', 'r', encoding='utf-8-sig') as songs_file: reader = DictReader(songs_file) for row in reader: new_song = model.Song(name=row['name']) # add artists artists = row['artists'].split(";") for artist_name in artists: print(artist_name) existing_artist = model.Artist.query.filter_by( name=artist_name).first() if (existing_artist): existing_artist.songs.append(new_song) new_song.artists.append(existing_artist) else: new_artist = model.Artist(name=artist_name) new_artist.songs.append(new_song) new_song.artists.append(new_artist) db.session.add(new_artist) # add movies movies = row['movies'].split(";") for movie_name in movies: print(movie_name) existing_movie = model.Movie.query.filter_by( name=movie_name).first() if (existing_movie): existing_movie.songs.append(new_song) new_song.movies.append(existing_movie) else: new_movie = model.Movie(name=movie_name)
def dodaj_post(): izbira = bottle.request.forms.getunicode("izbira") if izbira == '1': ime = bottle.request.forms.getunicode("vnos1") priimek = bottle.request.forms.getunicode("vnos2") datumRojstva = bottle.request.forms.getunicode("vnos3") spol = bottle.request.forms.getunicode("idS") drzava = bottle.request.forms.getunicode("vnos5") oseba = model.Oseba(ime, priimek, datumRojstva, spol, drzava) oseba.dodaj_v_bazo() bottle.redirect("/oseba/" + str(oseba.id)) elif izbira == '2': ime = bottle.request.forms.getunicode("vnos1") leto = bottle.request.forms.getunicode("vnos2") drzava = bottle.request.forms.getunicode("vnos3") mesto = bottle.request.forms.getunicode("vnos4") art = model.Artist(ime, leto, drzava, mesto) art.dodaj_v_bazo() koliko = bottle.request.forms.getunicode("koliko") if koliko != '': koliko = int(koliko) clani = [] for i in range(5, koliko + 1): temp = bottle.request.forms.getunicode("vnos{}".format(i)) clani.append(int(temp)) art.dodaj_clane(clani) bottle.redirect("/artist/" + str(art.id)) elif izbira == '3': naslov = bottle.request.forms.getunicode("vnos1") leto = bottle.request.forms.getunicode("vnos2") celotnaDolzina = 0 tip = bottle.request.forms.getunicode("vnos4") idZalozbe = bottle.request.forms.getunicode("id") if idZalozbe == '': idZalozbe = None else: idZalozbe = int(idZalozbe) izd = model.Izdaja(naslov, leto, tip, celotnaDolzina, idZalozbe) izd.dodaj_v_bazo() koliko = bottle.request.forms.getunicode("koliko") avtorji = [] if koliko != '': koliko = int(koliko) for i in range(6, koliko + 1): temp = bottle.request.forms.getunicode("vnos{}".format(i)) avtorji.append(int(temp)) izd.dodaj_avtorje(avtorji) bottle.redirect("/izdaja/" + str(izd.id)) elif izbira == '4': zanr = bottle.request.forms.getunicode('vnos1', '') model.Zanr(zanr).dodaj_v_bazo() bottle.redirect("/dodaj") elif izbira == '5': ime = bottle.request.forms.getunicode('vnos1', '') drzava = bottle.request.forms.getunicode('vnos2', '') model.Zalozba(ime, drzava).dodaj_v_bazo() bottle.redirect("/dodaj")