import string
from string import *
import time
from time import strftime, gmtime
import urllib, re, random, xml.dom.minidom
import httplib, Cookie
import xbmc, xbmcgui
import threading
import copy
import base64
try: Emulating = xbmcgui.Emulating
except: Emulating = False
conversion= { "á": "a", "é": "e", "í": "i", "ó": "o", "ú": "u",
"à": "a", "è": "e", "ì": "i", "ò": "o", "ù": "u",
"â": "a", "ê": "e", "î": "i", "ô": "o", "û": "u",
"ã": "a", "õ": "o", "ñ": "n", "ç":"c",
"Á": "A", "É": "E", "Í": "I", "Ó": "O", "Ú": "U",
"À": "A", "È": "E", "Ì": "I", "Ò": "O", "Ù": "U",
"Â": "A", "Ê": "E", "Î": "I", "Ô": "O", "Û": "U",
u"\xc2\xb4": "'", u"\xc3\xbc": "u", "Ñ": "N", "Ç": "C",
"Ü": "U", u"\xc3\x89":"E", u"\xc3\x80":"A", "ä":"a", "Ë":"E", "ë":"e",
u"\xc3\xa5":"a", u"\xc3\x81":"A", u"\xc3\xa2":"a", "ö":"o", "ð":"?", "ß":"ss",
u"\xc3\xa1":"a","å":"a", "ø":"o", "Ø":"O", "Þ":"?" , "æ":"ae",
u"\xc3\xa7":"c", u"\xc3\xa3":"a", u"\xc3\xba":"u", u"\xc3\xb3":"o",
u"\xc3\xad":"i", u"\xc3\xaa":"e", u"\xc3\xb4":"o", u"\xc3\xa9":"e",
u"\xc3\xb5":"o", u"\xc2\xaa":"a",
}
GloboSite = 'http://gmc.globo.com'
global user
global passw
global usuario
global passw2
global password
global user2
HTTP_TIMEOUT = 10.0 # Max. segundos de espera por resposta
DEFAULT_SIZE = 2 # 2=Large, 1=Medium, 0=Small, -1=Show dialog
ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4
ACTION_PAGE_UP = 5
ACTION_PAGE_DOWN = 6
ACTION_SELECT_ITEM = 7
ACTION_HIGHLIGHT_ITEM = 8
ACTION_PARENT_DIR = 9
ACTION_PREVIOUS_MENU = 10
ACTION_SHOW_INFO = 11
ACTION_PAUSE = 12
ACTION_STOP = 13
ACTION_NEXT_ITEM = 14
ACTION_PREV_ITEM = 15
DOWNLOAD_AND_PLAY = 1
# defines
STATE_HOJE = 1
STATE_ESPECIAL = 2
STATE_ESPECIAL_FILMES = 3
STATE_DIVERSAO = 4
STATE_DIVERSAO_FILMES = 5
STATE_JORNALISMO = 6
STATE_JORNALISMO_FILMES = 7
STATE_ESPORTE = 8
STATE_ESPORTE_FILMES = 9
STATE_ADICIONAL = 10
STATE_ADICIONAL_FILMES = 11
STATE_CONFIG = 12
links_hoje = {}
links_especial = {}
links_diversao = {}
links_esporte = {}
links_jornalismo = {}
links_adicional = {}
ids_hoje = {}
ids_especial = {}
ids_diversao = {}
ids_esporte = {}
ids_jornalismo = {}
ids_adicional = {}
links_integra = {}
links_filme = {}
links_filme_user = {}
tempo_filme = {}
links_exibicao = {}
links_integra = {}
alphanum_ops_CHECK=0
alphanum_ops_FIX=1
def recupparam():
global user
global passw
global passw2
global password
global user2
global usuario
try:
f=open('Q:\\SCRIPTS\senha.cfg',"r")
parametros=f.read()
f.close()
parametros=base64.decodestring(parametros)
user = extrai(parametros,'<login>','</login>',7)
passw = extrai(parametros,'<mdp>','</mdp>',5)
except:
user='user'
passw='pass'
user2 = user
usuario = user
passw2 = passw
password = passw
return
def extrai(parametros, ini, fim, nb):
try:
parametrosIni = string.index(parametros, ini, 0) + nb
parametrosFim = string.index(parametros, fim, parametrosIni)
return parametros[parametrosIni:parametrosFim]
except:
return none
return none
def _alphanum_util (string, operation):
"""check if all characters are in printable range
and valid in roman alphabet languages"""
global alphanum_ops_CHECK, alphanum_ops_FIX
global conversion
ok=1
out_string=""
skip=0
aux=len(string)
for i in xrange(aux):
if skip:
skip-=1
continue
char=string[i]
num=ord(char)
if num>=32 and num<=127:
out_string+=char
else:
if num> 127 and i<aux-1 and conversion.has_key (string[i]+string[i+1]):
out_string+=conversion[string[i]+string[i+1]]
skip=1
else:
out_string+="?"
ok=0
if operation==alphanum_ops_CHECK:
return ok
if num >= 0xf0:
skip=3
elif num >= 0xe0:
skip-2
elif num>= 0xc0:
skip=1
else:
skip=0
if operation==alphanum_ops_CHECK:
return ok
else:
return out_string
def check_alphanum (string):
"""check if all characters are in printable range and
valid in romam alphabet languages"""
global alphanum_ops_CHECK, alphanum_ops_FIX
return _alphanum_util (string, alphanum_ops_CHECK)
def strip_diacriticals (string):
"""replace non ASCII characters for '?' ' or equiv.
letter if it is an western european accented letter."""
global alphanum_ops_CHECK, alphanum_ops_FIX
return _alphanum_util (string, alphanum_ops_FIX)
def addToDictionary( dictionary, key, value):
if key not in dictionary:
dictionary[key] = value
else:
current = dictionary[key]
if type( current ) is types.DictType:
dictionary[key] = [current, value]
elif type( current[0] ) is types.DictType:
current.append( value )
elif type( current[0] ) is types.ListType:
current.append( value )
else:
dictionary[key] = [current, value]
def GetParse0(url):
file = urllib.urlopen(url)
data = file.read()
data = string.replace(data, chr(9), '')
data = string.replace(data, '&', '')
data = string.replace(data, '\n', '',6)
data = string.replace(data, ' ' , '',1)
data = string.replace(data, '\n', '',2)
data = string.replace(data, '\n\n', '\n')
data = string.replace(data, '\n\n', '\n')
data = string.replace(data, '><', '>\n<')
return data
def GetParse1(url):
file = urllib.urlopen(url)
data = file.read()
data = string.replace(data, chr(9), '')
data = string.replace(data, '&', '')
data = string.replace(data, '\n', '',22)
data = string.replace(data, '\n\n', '\n')
data = string.replace(data, '\n\n', '\n')
data = string.replace(data, ' <', '<')
data = string.replace(data, ' <grupomc', '<grupomc')
data = string.replace(data, ' </grupo>', '</grupo>')
data = string.replace(data, ' <descricao', '<descricao')
data = string.replace(data, ' <midiaid', '<midia id')
data = string.replace(data, ' <midiaid', '<midia id')
data = string.replace(data, 'grupo>\n<grupomc', 'grupo>\n\n<grupomc')
return data