def test_errors(self):
        resp = self.app.get('/api/info?%s' % compat_urllib_parse.urlencode({'url': 'http://www.google.com'}))
        self.assertEqual(resp.status_code, 500)
        info = json.loads(resp.data.decode(resp.charset))
        self.assertIn('error', info)

        resp = self.app.get('/api/info?%s' % compat_urllib_parse.urlencode({'url': 'foo', 'playlistreverse': 'invalid'}))
        self.assertEqual(resp.status_code, 400)
        info = json.loads(resp.data.decode(resp.charset))
        self.assertIn('error', info)
Beispiel #2
0
 def _request(self, params):
     param_str = compat_urllib_parse.urlencode(params)
     try:
         req = compat_urllib_request.urlopen(self.url + '?' + param_str)
         return req.code, req.read().decode('utf-8')
     except compat_HTTPError as he:
         return he.code, he.read().decode('utf-8')
    def test_errors(self):
        resp = self.app.get(
            '/api/info?%s' %
            compat_urllib_parse.urlencode({'url': 'http://www.google.com'}))
        self.assertEqual(resp.status_code, 500)
        info = json.loads(resp.data.decode(resp.charset))
        self.assertIn('error', info)

        resp = self.app.get(
            '/api/info?%s' %
            compat_urllib_parse.urlencode({
                'url': 'foo',
                'playlistreverse': 'invalid'
            }))
        self.assertEqual(resp.status_code, 400)
        info = json.loads(resp.data.decode(resp.charset))
        self.assertIn('error', info)
Beispiel #4
0
def api():
    response = redirect(
        '/api/info?%s' % compat_urllib_parse.urlencode(request.args), 301)
    response.headers['Deprecated'] = 'Use "/api/info" instead'
    return response
Beispiel #5
0
 def get_video_info(self, url, flatten=True):
     args = {
         'url': url,
         'flatten': flatten,
     }
     return self.get_json('/api/info?%s' % compat_urllib_parse.urlencode(args))
 def get_video_info(self, url, **kwargs):
     args = dict(url=url, **kwargs)
     return self.get_json('/api/info?%s' % compat_urllib_parse.urlencode(args))
 def get_video_info(self, url, **kwargs):
     args = dict(url=url, **kwargs)
     return self.get_json('/api/info?%s' %
                          compat_urllib_parse.urlencode(args))
def api():
    response = redirect("/api/info?%s" % compat_urllib_parse.urlencode(request.args), 301)
    response.headers["Deprecated"] = 'Use "/api/info" instead'
    return response
Beispiel #9
0
 def test_play(self):
     resp = self.app.get('/api/play?%s' %
                         compat_urllib_parse.urlencode({'url': 'test:ted'}))
     self.assertEqual(resp.status_code, 302)
 def test_play(self):
     resp = self.app.get('/api/play?%s' % compat_urllib_parse.urlencode({'url': 'test:ted'}))
     self.assertEqual(resp.status_code, 302)