# -*- coding: utf-8 -*- import mimetypes import os import re import sys from flask import abort, Flask, Response, request, send_file from shiva.config import Configurator from shiva.utils import get_logger app = Flask(__name__) app.config.from_object(Configurator()) log = get_logger() RANGE_RE = re.compile(r'(\d+)-(\d*)') @app.after_request def after_request(response): response.headers['Accept-Ranges'] = 'bytes' return response def get_absolute_path(relative_path): for mdir in app.config.get('MEDIA_DIRS', []): full_path = os.path.join(mdir.root, relative_path) for excluded in mdir.get_excluded_dirs(): if full_path.startswith(excluded):
import re import urllib2 import urllib import lxml.html import requests from flask import current_app as app from shiva.lyrics import LyricScraper from shiva.utils import get_logger log = get_logger() class MetroLyrics(LyricScraper): """ """ def __init__(self, artist, title): self.artist = artist self.title = title self.search_url = 'http://www.metrolyrics.com/api/v1/search/artistsong' self.title_re = re.compile(r'<title>(?P<artist>.*?) - ' r'(?P<title>.*?) LYRICS</title>') self.lyrics = None self.source = None def fetch(self): self.search() if not self.source: return None