当前位置: 首页>>代码示例>>Python>>正文


Python Album.get方法代码示例

本文整理汇总了Python中models.Album.get方法的典型用法代码示例。如果您正苦于以下问题:Python Album.get方法的具体用法?Python Album.get怎么用?Python Album.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Album的用法示例。


在下文中一共展示了Album.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_photo

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
	def add_photo(self, album_id=''):
		if request.method == 'POST':
			album = Album.get(id=album_id)
			photo = Photo()
			photo.album = album
			file = request.files['files']
			photo_title, size, photo_path, photo_url, thumb_url, thumb_path = self.gal_man.add_photo(album, file)
			result = []
			result.append({
				'name':photo_title,
				'size':size,
				'url':photo_url,
				'thumbnail_url':thumb_path,
				"delete_type":"POST",
			})
			photo.title = photo_title
			photo.photo_path = photo_path
			photo.thumb_path = thumb_path
			photo.photo_url = photo_url
			photo.thumb_url = thumb_url
			photo.size = size
			photo.save()
			return json.dumps(result)
		else:
			return 'response'
开发者ID:lpfan,项目名称:Wing-M.S.,代码行数:27,代码来源:gallery.py

示例2: show_album

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
	def show_album(self, album_id=''):
		album=None
		try:
			album = Album.get(id=album_id)
		except DoesNotExist:
			print 'album does not exists'
		return self.render('admin/show_album.html', album=album)
开发者ID:lpfan,项目名称:Wing-M.S.,代码行数:9,代码来源:gallery.py

示例3: next

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
 def next(self, request, **kwargs):
   if request.GET['album'] and request.GET['track_num']:
     song = Song.get_song(int(request.GET['album']), int(request.GET['track_num']))
   if request.GET['album'] and not song:
     song = Album.get_similar_album(request.GET['album']).song_set[0]
   if not song:
     song = Album.get(0).song_set[0]
   bundle = self.build_bundle(obj=song, request=request)
   bundle = self.full_dehydrate(bundle)
   return self.create_response(request, { 'song': bundle })
开发者ID:baugarten,项目名称:Heartbeat,代码行数:12,代码来源:api.py

示例4: sync_to

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
    def sync_to(self, sync_cls):
        objs = []
        # traverse the dir
        for dirpath, folders, files in os.walk(self.folder):
            for fname in files:
                fpath = os.path.join(dirpath, fname)
                # get album, if have
                rel = os.path.relpath(dirpath, self.folder)
                if rel != '.':  # has sub dir
                    try:
                        album = Album.get(name=rel)
                    except Album.DoesNotExist:
                        album = Album.create(name=rel, folder=rel)
                else:
                    album = None
                # TODO: should a file extension filter here?
                md5 = hashlib.md5(open(fpath).read()).hexdigest()
                try:  # if file has been exists before
                    local = Local.get(md5=md5)
                    opath = local.path.encode('utf8')
                    if opath != fpath:
                        logging.debug('%s path change: %s --> %s' % (local, local.path, fpath))
                        # file was moved, rename filename or folder
                        local.title, ext = os.path.splitext(fname)
                        local.album = album
                        #local.fpath = fpath
                        local.last_modified = datetime.datetime.now()
                        local.save()
                        objs.append(local)  # objs: path modified.
                except Local.DoesNotExist:  # new file
                    try:
                        # file content modified
                        local = Local.get(path=fpath)
                        logging.debug('%s modified, path: %s' % (local, fpath))
                    except Local.DoesNotExist:
                        # brand new file
                        logging.debug('new file %s' % fpath)
                        local = Local()
                        local.title, ext = os.path.splitext(fname)
                        local.album = album
                        local.path = fpath
                    local.md5 = md5
                    local.last_modified = datetime.datetime.now()
                    local.save()
                    objs.append(local)

        # for those have not been upload
        for l in Local.select():
            sets = getattr(l, sync_cls.model.local.related_name)
            if sets.count() == 0 and l not in objs:
                objs.append(l)

        # pass objs that needs update to sync class
        logging.info('local: sync to %s, count %d' % (sync_cls, len(objs)))
        sync_cls.sync_from_local(objs)
开发者ID:oneyoung,项目名称:flickr-sync,代码行数:57,代码来源:local.py

示例5: remove_album

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
	def remove_album(self, album_id=''):
		try:
			album = Album.get(id=album_id)
			album.delete_instance(recursive=True)
			shutil.rmtree(album.album_path)
			shutil.rmtree(album.thumb_path)
			flash(u"Альбом %s видалено успішно" % album.title)
			return redirect(url_for('.index'))
		except DoesNotExist:
			print "album does not exist"
		flash(u"Такого альбому не існує")
		return redirect(url_for('.index'))
开发者ID:lpfan,项目名称:Wing-M.S.,代码行数:14,代码来源:gallery.py

示例6: addReleases

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
def addReleases(artist_id, update_artist = True):
  artist_record = Artist.get(id=artist_id)
  musicbrainz_artist = musicbrainz.getBestArtistMatch(artist_record.name)
  release_ids = []

  for release in musicbrainz_artist.getReleases():
    release_ids.append(utils.extractUuid(release.id))

  # These release results do not contain all the information, we must re-query for that info...
  for rid in release_ids:
    release = musicbrainz.getRelease(rid)

    if not release: continue

    release_group_id = utils.extractUuid(release.getReleaseGroup().id)

    try:
      release_group_tracked = Album.get(release_group_id=release_group_id)
    except peewee.DoesNotExist:
      release_group_tracked = None

    if release_group_tracked: continue

    release_record = Album.create(
        musicbrainz_id = rid,
        asin = release.getAsin(),
        release_group_id = release_group_id,
        artist_id = artist_id,
        name = release.getTitle(),
        type = release.getType(),
        released_on = release.getEarliestReleaseDate(),
        state = 'wanted')

    track_number = 1

    for track in release.getTracks():
      Track.create(
          album_id = release_record.id,
          number = track_number,
          title = track.getTitle(),
          length = track.getDuration(),
          state = 'wanted')

      track_number += 1

  # Rescan the Music Library after adding new releases to see if the user has 
  # them or not. Will not run if explicitly told not to by the caller.
  if(update_artist): ThreadPool.put(updateArtist, {'artist_id': artist_id})
开发者ID:JohnPostlethwait,项目名称:headphones-two,代码行数:50,代码来源:filescanner.py

示例7: put

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
 def put(self, image_id):
     image_id = int(image_id)
     image = Image.get(id=image_id)
     if not image:
         raise tornado.web.HTTPError(404)
     album_id = self.get_int('album_id', None)
     if not album_id:
         return self.send_error_result(msg=u'没有指定专辑哦')
     album = Album.get(id=album_id)
     if not album:
         return self.send_error_result(msg=u'专辑不存在')
     if album.user_id != self.current_user.id:
         return self.send_error_result(msg=u'此专辑不是您的专辑')
     if image.album_id != album_id:
         image.album_id = album_id
     return self.send_success_result()
开发者ID:ljtyzhr,项目名称:collipa,代码行数:18,代码来源:image.py

示例8: album

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
    def album(self, id):
        album = Album.get(id=id)
        title = album.artist.name + " &emdash; " + album.name

        return self.serve_template("album.html", album=album, title=title)
开发者ID:JohnPostlethwait,项目名称:headphones-two,代码行数:7,代码来源:controller.py

示例9: get

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import get [as 别名]
 def get(self, album_id):
     album_id = int(album_id)
     album = Album.get(id=album_id)
     if not album:
         raise tornado.web.HTTPError(404)
     return self.render("album/index.html", album=album, page=self.page)
开发者ID:hallocrowc,项目名称:collipa,代码行数:8,代码来源:album.py


注:本文中的models.Album.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。