"""
urlresolver XBMC Addon
Copyright (C) 2011 t0mm0
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 3 of the License, 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. If not, see .
"""
import re
import os
import urllib
from urlresolver import common
from urlresolver.resolver import UrlResolver, ResolverError
class VeeHDResolver(UrlResolver):
name = "VeeHD"
domains = ["veehd.com"]
pattern = '(?://|\.)(veehd\.com)/video/([0-9A-Za-z]+)'
profile_path = common.profile_path
cookie_file = os.path.join(profile_path, '%s.cookies' % name)
def __init__(self):
self.net = common.Net()
try: os.makedirs(os.path.dirname(self.cookie_file))
except OSError: pass
# UrlResolver methods
def get_media_url(self, host, media_id):
if not self.get_setting('login') == 'true' or not (self.get_setting('username') and self.get_setting('password')):
raise ResolverError('VeeHD requires a username & password')
web_url = self.get_url(host, media_id)
html = self.net.http_GET(web_url).content
# two possible playeriframe's: stream and download
for match in re.finditer('playeriframe.+?src\s*:\s*"([^"]+)', html):
player_url = 'http://%s%s' % (host, match.group(1))
html = self.net.http_GET(player_url).content
# if the player html contains an iframe the iframe url has to be gotten and then the player_url tried again
r = re.search('' % (cls.__name__))
xml.append('' % (cls.__name__))
xml.append('' % (cls.__name__))
return xml