Пример #1
0
# -*- coding:utf-8 -*-
from . import realpath
from . import setting
import random
from bson import ObjectId
import redis
import time
import hashlib
import json

from models.anime_music import model

tb_anime = model.AnimeList()
tb_music = model.MusicList()

r = redis.Redis(host='127.0.0.1', port=6379, db=0)


def GetSignUrl(id):
    timeout = int(time.time() + 3600)
    m2 = hashlib.md5()
    m2.update(('%s%s{AnimeToken}' % (id, timeout)).encode('utf-8'))
    return '%s/%s_128.mp3?t=%s&sign=%s' % (setting.FILESERVERHOST, id, timeout,
                                           m2.hexdigest().upper())


def get_music_info(id, recommend):
    if not id or not ObjectId.is_valid(id):
        id = ObjectId(get_random_id(recommend))
    else:
        id = ObjectId(id)
Пример #2
0
# coding=utf-8
from __future__ import absolute_import
import realpath

from models.anime_music import model

tb_anime_list = model.AnimeList()
tb_anime_list.ensure_index([('title', -1), ('atime', -1)])
tb_anime_list.ensure_index([('_id', -1), ('atime', -1)])
tb_anime_list.ensure_index('tietukuname')

music_list = model.MusicList()
music_list.ensure_index('atime')
music_list.ensure_index('recommend')
music_list.ensure_index([('title', -1), ('atime', -1)])
music_list.ensure_index([('_id', -1), ('atime', -1)])
music_list.ensure_index([('anime_id', -1), ('atime', -1)])