1 Star 0 Fork 120

畅通无阻/NetEaseMusic

forked from cosven/FeelUOwn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
models.py 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
cosven 提交于 2015-05-05 19:23 . refactor : python2 to python3
# -*- coding=utf8 -*-
__author__ = 'cosven'
class DataModel(object):
def user(self):
user_model = {
'uid': int,
'username': str,
'avatar': str
}
return user_model
def music(self):
music_model = {
'id': int,
'name': str,
'artists': list,
'album': dict,
'duration': str,
'mp3Url': str
}
return music_model
def playlist(self):
playlist_model = {
'id': int,
'name': str
}
return playlist_model
def search_result(self):
"""
from search result: data['result']['songs']
"""
search_list = {
'id': int,
'name': str,
'artists': list,
'album': dict
}
return search_list
def set_datamodel_from_data(self, data, datamodel):
"""
before generating model, the data should be validated
requirement: the datastructure of model is similar with standard
:param data: dict, input data
:param type: string, the target model type
"""
# temperarily: no validation check
for key in datamodel:
datamodel[key] = data[key]
return datamodel
def validate(self, data, model_type):
"""
compare data with the standard model, to validate the data basicllay.
1. check those keys which data must contain
:param data: dict type,
:param model: dict type, standard data model. base on the doc
:return: if validated: true
"""
return True
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fc500110/NetEaseMusic.git
[email protected]:fc500110/NetEaseMusic.git
fc500110
NetEaseMusic
NetEaseMusic
master

搜索帮助