From fd9f3812be8198f5003d3f4e545ad6d7827be2c2 Mon Sep 17 00:00:00 2001 From: jose1711 Date: Thu, 23 Nov 2017 01:00:42 +0100 Subject: [PATCH 1/2] Add basic support dailymotion videos --- addon.xml | 2 +- changelog.txt | 4 +- lib/server/dailymotionresolver.py | 82 +++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 lib/server/dailymotionresolver.py diff --git a/addon.xml b/addon.xml index 25a317d..e435f75 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/changelog.txt b/changelog.txt index 5583ff0..352ec7c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ +[B]1.6.53:[/B] +- add dailymotion resolver [B]1.6.52:[/B] -- fix streamujtv reslover +- fix streamujtv resolver [B]1.6.48:[/B] - fixed video download code which was failing when there were subtitles to download diff --git a/lib/server/dailymotionresolver.py b/lib/server/dailymotionresolver.py new file mode 100644 index 0000000..5f6f9a1 --- /dev/null +++ b/lib/server/dailymotionresolver.py @@ -0,0 +1,82 @@ +# -*- coding: UTF-8 -*- +# * +# * +# * This Program is free software; you can redistribute it and/or modify +# * it under the terms of the GNU General Public License as published by +# * the Free Software Foundation; either version 2, or (at your option) +# * any later version. +# * +# * This Program is distributed in the hope that it will be useful, +# * but WITHOUT ANY WARRANTY; without even the implied warranty of +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# * GNU General Public License for more details. +# * +# * You should have received a copy of the GNU General Public License +# * along with this program; see the file COPYING. If not, write to +# * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# * http://www.gnu.org/copyleft/gpl.html +# * + +import re +from xml.etree import ElementTree +import util +from copy import deepcopy +import requests +import json + +__name__ = 'dailymotion' + + +def supports(url): + return re.search(r'dailymotion.com/embed', url) is not None + + +def resolve(url): + print 'The url is ::', url + id = re.search(r'dailymotion.com/embed/video/(.+)', url).group(1) + print 'The id is ::', id + headers = {'User-Agent': 'Android'} + cookie = {'Cookie': "lang=en; ff=off"} + r = requests.get("http://www.dailymotion.com/player/metadata/video/" + id, + headers=headers, + cookies=cookie) + content = r.json() + cc = content['qualities'] + cc = cc.items() + + cc = sorted(cc, reverse=True) + m_url = '' + other_playable_url = [] + + items = [] + result = [] + + for source, json_source in cc: + source = source.split("@")[0] + for item in json_source: + + m_url = item.get('url', None) + # xbmc.log("DAILYMOTION - m_url = %s" % m_url, xbmc.LOGNOTICE) + if m_url: + if source == "auto": + continue + + elif '.mnft' in m_url: + continue + + if 'video' in item.get('type', None): + item = {} + item['url'] = m_url + item['quality'] = source + item['title'] = 'video' + items.append(item) + + other_playable_url.append(m_url) + + if items: + for item in items: + newitem = deepcopy(item) + item['lang'] = '???' + item['headers'] = headers + result.append(newitem) + return result From b5fedcefad843550aa723d9401283eae4535f48f Mon Sep 17 00:00:00 2001 From: jose1711 Date: Sun, 26 Nov 2017 00:41:40 +0100 Subject: [PATCH 2/2] Update rutube resolver --- lib/server/rutuberesolver.py | 60 +++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/lib/server/rutuberesolver.py b/lib/server/rutuberesolver.py index 4076680..b45467d 100644 --- a/lib/server/rutuberesolver.py +++ b/lib/server/rutuberesolver.py @@ -1,5 +1,4 @@ # -*- coding: UTF-8 -*- -#/* # * Copyright (C) 2011 Libor Zoubek # * # * @@ -18,24 +17,55 @@ # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # * http://www.gnu.org/copyleft/gpl.html # * -# */ -import re,util +import re +import util +import json __name__ = 'rutube' + + def supports(url): - return not _regex(url) == None + return not _regex(url) is None -# returns the steam url + +# returns the stream url def url(url): - m = _regex(url) - if m: - data = util.request('http://rutube.ru/trackinfo/'+m.group('id')+'.xml') - n = re.search('([^<]+)',data,re.IGNORECASE | re.DOTALL) - if not n == None: - return [n.group(1).strip()] + m = _regex(url) + if m: + data = util.request('http://rutube.ru/' + m.group(1) + '/' + + m.group(2)) + n = re.search('canonical" href="(?Phttps://rutube.ru/[^"]+)"', + data, + re.IGNORECASE | re.DOTALL) + nurl = n.group('url') + print('url: %s' % nurl) + n = re.search(r'/(?P[\da-z]{32})/?$', nurl, + re.IGNORECASE | re.DOTALL) + id = n.group('id') + print('id: %s' % id) + data = util.request('https://rutube.ru/api/play/options/%s/?format=json' % id) + jsondata = json.loads(data) + nurl = jsondata['video_balancer']['m3u8'] + data = util.request(nurl) + result = [] + for line in data.splitlines(): + if 'http' in line: + result.append(line.strip()) + + return result + def resolve(u): - stream = url(u) - if stream: - return [{'name':__name__,'quality':'640p','url':stream[0],'surl':u}] + streams = url(u) + result = [] + if streams: + for stream in streams: + result.append({'name': __name__, + 'quality': '???', + 'url': stream, 'surl': u, 'title': 'rutube stream'}) + return result + + def _regex(url): - return re.search('rutube\.ru/(video/embed|embed)/(?P[^$]+)',url,re.IGNORECASE | re.DOTALL) + return re.search('rutube\.ru/(play/embed|video/embed|embed)/(?P[^$]+)', + url, + re.IGNORECASE | re.DOTALL)