def search_poster(id):
    url = 'http://www.kinopoisk.ru/level/17/film/%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    coveritems = []
    watchvideopage.close()
    if '<table class="fotos' in data:
        coveritems = multiValue(data, '<table class="fotos.*?">(.*?)</table>', '<a href="(.*?)">')
        Coverart = coveritems[0]
        url2 = 'http://www.kinopoisk.ru%s' % Coverart
        watchrequest2 = Request(url2, None, std_headers)
        try:
            watchvideopage2 = urlopen2(watchrequest2)
        except (URLError, HTTPException, socket.error) as err:
            print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

        data2 = watchvideopage2.read().decode('cp1251').encode('utf-8')
        coveritem = ''
        coveritem = singleValue(data2, '<img style=".*?" id="image" src="(.*?)".*?/>')
        watchvideopage2.close()
    else:
        coveritem = 'None'
    return coveritem
def search_poster(id):
    url = 'http://www.kinopoisk.ru/level/17/film/%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    coveritems = []
    watchvideopage.close()
    if '<table class="fotos' in data:
        coveritems = multiValue(data, '<table class="fotos.*?">(.*?)</table>',
                                '<a href="(.*?)">')
        Coverart = coveritems[0]
        url2 = 'http://www.kinopoisk.ru%s' % Coverart
        watchrequest2 = Request(url2, None, std_headers)
        try:
            watchvideopage2 = urlopen2(watchrequest2)
        except (URLError, HTTPException, socket.error) as err:
            print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
                err)

        data2 = watchvideopage2.read().decode('cp1251').encode('utf-8')
        coveritem = ''
        coveritem = singleValue(
            data2, '<img style=".*?" id="image" src="(.*?)".*?/>')
        watchvideopage2.close()
    else:
        coveritem = 'None'
    return coveritem
Exemplo n.º 3
0
def taobao_watch():
    begin_time = time.time()
    param = dict(
        timestamp=datetime.datetime.now(),
        app_key=KEY,
    )
    param['sign'] = taobao_sign(OAUTH.TAOBAO.SECRET, param)
    urlopen2(URL, data=urlencode(param)).headers
    s = socket.socket()
    s.connect(('stream.api.taobao.com', 80))
    content = urlencode(param)
    s.send("\r\n".join([
        'POST /stream HTTP/1.0',
        'Content-Type: application/x-www-form-urlencoded',
        'Content-Length: %s' % len(content), 'Host: stream.api.taobao.com', '',
        content
    ]))

    s.setblocking(False)
    running = True
    data = ""
    skip = True
    while running:
        try:
            while True:
                data += s.recv(4000)
                if len(data) == 0:
                    running = False
                    break
                while 1:
                    if "\r\n" in data:
                        (line, data) = data.split("\r\n", 1)
                        if skip is True:
                            if not line:
                                skip = False
                        else:
                            line = loads(line)
                            code = line['packet']['code']
                            if code not in (201, 200, 203):
                                yield line
                    else:
                        break
        except socket.error, e:
            no = e[0]
            if no == errno.EINTR:
                continue
            elif no != errno.EAGAIN:  # Resource temporarily unavailable
                print e
                s.close()
                raise
        if (time.time() - begin_time) > 3600:
            return
        time.sleep(.3)
Exemplo n.º 4
0
	def getVideoUrl(self):
		'''VIDEO_FMT_PRIORITY_MAP = {
			'38' : 1, #MP4 Original (HD)
			'37' : 2, #MP4 1080p (HD)
			'22' : 3, #MP4 720p (HD)
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}'''
		VIDEO_FMT_PRIORITY_MAP = {
			'34' : 2, #FLV 360p
			'35' : 1, #FLV 480p
			'18' : 3, #MP4 360p
			'22' : 4, #MP4 720p (HD)
			'37' : 5, #MP4 1080p (HD)
			'38' : 6, #MP4 Original (HD)  
		}
		
		video_url = None
		video_id = str(self.getTubeId())

		links = {}
		watch_url = 'http://www.youtube.com/watch?v=%s&safeSearch=none'%video_id
		watchrequest = Request(watch_url, None, std_headers)

		try:
			print "[MyTube] trying to find out if a HD Stream is available",watch_url
			result = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
def poster_viem(id):
    url = 'http://www.kinopoisk.ru/level/17/film/%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    search_results = []
    watchvideopage.close()
    if '<table class="fotos' in data:
        content_results = singleValue(data, '<table class="fotos.*?">(.*?)</table>')
        if content_results:
            results = CrewRoleList3(content_results)
            idposters = re.compile('<a href="(.*?)" target="_blank" title="\xd0\x9e\xd1\x82\xd0\xba\xd1\x80\xd1\x8b\xd1\x82\xd1\x8c \xd0\xb2 \xd0\xbd\xd0\xbe\xd0\xb2\xd0\xbe\xd0\xbc \xd0\xbe\xd0\xba\xd0\xbd\xd0\xb5"></a>').findall(content_results)
            imageslinks = re.compile('<img  src="(.*?)".*?/></a>').findall(content_results)
            imagessaizes = re.compile('<span class="genre">(.*?)</span>').findall(results)
            for imagessaize in imagessaizes:
                search_results.append('size:' + imagessaize)

            i = 0
            for idposter in idposters:
                if i < len(idposters):
                    search_results[i] = search_results[i] + '\n\n (' + idposter + ')'
                i += 1

            l = 0
            for imageslink in imageslinks:
                if l < len(imageslinks):
                    search_results[l] = search_results[l] + '\n link:' + imageslink + 'end'
                l += 1

    return search_results
Exemplo n.º 6
0
def getMovieUrl(url):
	req = Request(url, None, std_headers)
	try:
		txt = urlopen2(req).read()
	except (URLError, HTTPException, error) as err:
		print("[ZDFMediaThek] Error: Unable to retrieve videopage - Error code: ", str(err))
		return ""

	if ('rtsp' in txt) and ('.mp4' in txt):
		idx = txt.index('rtsp')
		idx2 = txt.index('.mp4')
		return txt[idx:idx2 + 4]
	if ('rtsp' in txt) and ('.sdp' in txt):
		idx = txt.index('rtsp')
		idx2 = txt.index('.sdp')
		return txt[idx:idx2 + 4]
	elif ('mms' in txt) and ('.wmv' in txt):
		idx = txt.index('mms')
		idx2 = txt.index('.wmv')
		return txt[idx:idx2 + 4]
	elif ('http' in txt) and ('.asx?' in txt):
		idx = txt.index('http')
		idx2 = txt.index('.asx?')
		return txt[idx:idx2 + 4]
	elif ('mms' in txt) and ('reflector:' in txt):
		idx = txt.index('mms')
		idx2 = txt.index('" />')
		return txt[idx:idx2]
	else:
		return None
Exemplo n.º 7
0
def poster_viem(id):
    url = 'http://www.kinopoisk.ru/level/17/film/%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    search_results = []
    watchvideopage.close()
    if '<table class="fotos' in data:
        content_results = singleValue(data, '<table class="fotos.*?">(.*?)</table>')
        if content_results:
            results = CrewRoleList3(content_results)
            idposters = re.compile('<a href="(.*?)" target="_blank" title="\xd0\x9e\xd1\x82\xd0\xba\xd1\x80\xd1\x8b\xd1\x82\xd1\x8c \xd0\xb2 \xd0\xbd\xd0\xbe\xd0\xb2\xd0\xbe\xd0\xbc \xd0\xbe\xd0\xba\xd0\xbd\xd0\xb5"></a>').findall(content_results)
            imageslinks = re.compile('<img  src="(.*?)".*?/></a>').findall(content_results)
            imagessaizes = re.compile('<span class="genre">(.*?)</span>').findall(results)
            for imagessaize in imagessaizes:
                search_results.append('size:' + imagessaize)

            i = 0
            for idposter in idposters:
                if i < len(idposters):
                    search_results[i] = search_results[i] + '\n\n (' + idposter + ')'
                i += 1

            l = 0
            for imageslink in imageslinks:
                if l < len(imageslinks):
                    search_results[l] = search_results[l] + '\n link:' + imageslink + 'end'
                l += 1

    return search_results
Exemplo n.º 8
0
    def getVideoUrl(self):
        '''VIDEO_FMT_PRIORITY_MAP = {
			'38' : 1, #MP4 Original (HD)
			'37' : 2, #MP4 1080p (HD)
			'22' : 3, #MP4 720p (HD)
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}'''
        VIDEO_FMT_PRIORITY_MAP = {
            '34': 2,  #FLV 360p
            '35': 1,  #FLV 480p
            '18': 3,  #MP4 360p
            '22': 4,  #MP4 720p (HD)
            '37': 5,  #MP4 1080p (HD)
            '38': 6,  #MP4 Original (HD)  
        }

        video_url = None
        video_id = str(self.getTubeId())

        links = {}
        watch_url = 'http://www.youtube.com/watch?v=%s&safeSearch=none' % video_id
        watchrequest = Request(watch_url, None, std_headers)

        try:
            print "[MyTube] trying to find out if a HD Stream is available", watch_url
            result = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket.error), err:
            print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(
                err)
            return video_url
def poster_viemtmbd(id):
    url = 'http://www.themoviedb.org%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    data = watchvideopage.read()
    search_results = []
    watchvideopage.close()
    if '<div id="images">' in data:
        content_results = singleValue(data, '<div id="images">(.*?)</div>')
        if content_results:
            idposters = re.compile(
                '<img itemprop=".*?" class=".*?" id=".*?" src="(.*?)" width=".*?" height=".*?" />'
            ).findall(content_results)
            imagessaizes = re.compile(
                '<img itemprop=".*?" class=".*?" id="(.*?)" src=".*?" width=".*?" height=".*?" />'
            ).findall(content_results)
            for imagessaize in imagessaizes:
                search_results.append('image:' + imagessaize)

            l = 0
            for idposter in idposters:
                if l < len(idposters):
                    search_results[
                        l] = search_results[l] + '\n link:' + idposter + 'end'
                l += 1

    return search_results
Exemplo n.º 10
0
	def getVideoUrl(self, entry):
		std_headers = {
			'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
			'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
			'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
			'Accept-Language': 'en-us,en;q=0.5',
		}

		VIDEO_FMT_PRIORITY_MAP = {
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}

		if int(config.plugins.yttrailer.best_resolution.value) <= 1:
			VIDEO_FMT_PRIORITY_MAP["38"] = 1 #MP4 Original (HD)
			VIDEO_FMT_PRIORITY_MAP["22"] = 3 #MP4 720p (HD)

			if int(config.plugins.yttrailer.best_resolution.value) == 0:
				VIDEO_FMT_PRIORITY_MAP["37"] = 2 #MP4 1080p (HD)

		video_url = None
		video_id = str(self.getTubeId(entry))

		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[YTTrailer] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket_error), err:
			print "[YTTrailer] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
Exemplo n.º 11
0
class PlayerLauncher:
    def getVideoUrl(self, video_id):
        video_url = None

        if video_id is None or video_id == "":
            return video_url

        # Getting video webpage
        watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            #print "trying to find out if a HD Stream is available",watch_url
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket.error), err:
            print "Error: Unable to retrieve watchpage - Error code: ", str(
                err)
            return video_url

        # Get video info
        for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
            info_url = (
                'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
                % (video_id, el))
            request = Request(info_url, None, std_headers)
            try:
                infopage = urlopen2(request).read()
                videoinfo = parse_qs(infopage)
                if ('url_encoded_fmt_stream_map'
                        or 'fmt_url_map') in videoinfo:
                    break
            except (URLError, HTTPException, socket.error), err:
                print "Error: unable to download video infopage", str(err)
                return video_url
Exemplo n.º 12
0
def getMovieUrl(url):
	req = Request(url, None, std_headers)
	try:
		txt = urlopen2(req).read()
	except (URLError, HTTPException, error), err:
		print "[ZDFMediaThek] Error: Unable to retrieve videopage - Error code: ", str(err)
		return ""
Exemplo n.º 13
0
def __get_tick_quotes_finam__(symbol, start_date, end_date, verbose=False):
    start_date = datetime.strptime(start_date, "%Y%m%d").date()
    end_date = datetime.strptime(end_date, "%Y%m%d").date()
    delta = end_date - start_date
    data = DataFrame()
    for i in range(delta.days + 1):
        day = timedelta(i)
        url = __get_url__(symbol, periods['tick'], start_date + day,
                          start_date + day, verbose)
        req = Request(url)
        req.add_header(
            'Referer',
            'http://www.finam.ru/analysis/profile0000300007/default.asp')
        r = urlopen2(req)
        try:
            tmp_data = read_csv(r,
                                index_col=0,
                                parse_dates={
                                    'index': [0, 1]
                                },
                                sep=';').sort_index()
            if data.empty:
                data = tmp_data
            else:
                data = data.append(tmp_data)
        except Exception:
            print('error on data downloading {} {}'.format(
                symbol, start_date + day))

    data.columns = [symbol + '.' + i for i in ['Last', 'Vol', 'Id']]
    return data
def poster_viemtmbd(id):
    url = 'http://www.themoviedb.org%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    watchvideopage.close()
    if '<div id="images">' in data:
        content_results = singleValue(data, '<div id="images">(.*?)</div>')
        if content_results:
            idposters = re.compile('<img itemprop=".*?" class=".*?" id=".*?" src="(.*?)" width=".*?" height=".*?" />').findall(content_results)
            imagessaizes = re.compile('<img itemprop=".*?" class=".*?" id="(.*?)" src=".*?" width=".*?" height=".*?" />').findall(content_results)
            for imagessaize in imagessaizes:
                search_results.append('image:' + imagessaize)

            l = 0
            for idposter in idposters:
                if l < len(idposters):
                    search_results[l] = search_results[l] + '\n link:' + idposter + 'end'
                l += 1

    return search_results
def search_comets(id):
    url = 'http://www.kinopoisk.ru/level/1/film/' + id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find(
        '<p class="more_random">'
    ):content.find(
        '\xd0\x94\xd0\xbb\xd1\x8f \xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd1\x87\xd1\x82\xd0\xbe\xd0\xb1\xd1\x8b \xd0\xb4\xd0\xbe\xd0\xb1\xd0\xb0\xd0\xb2\xd0\xb8\xd1\x82\xd1\x8c \xd1\x80\xd0\xb5\xd1\x86\xd0\xb5\xd0\xbd\xd0\xb7\xd0\xb8\xd1\x8e \xd0\xbd\xd0\xb0 \xd1\x84\xd0\xb8\xd0\xbb\xd1\x8c\xd0\xbc, \xd0\xbd\xd0\xb5\xd0\xbe\xd0\xb1\xd1\x85\xd0\xbe\xd0\xb4\xd0\xb8\xd0\xbc\xd0\xbe'
    )]
    if content_results:
        results = CrewRoleList2(content_results)
        names = normilize_string(
            singleValue(
                results,
                '<p class="profile_name"><s></s><a href=".*?" itemprop="name">(.*?)</a></p>'
            ))
        titleitems = normilize_string(
            singleValue(
                results,
                '<span class="_reachbanner_" itemprop="reviewBody">(.*?)</span></p> </div>'
            ))
        iditems = normilize_string(
            singleValue(results, '<p class="sub_title" id=".*?">(.*?)</p>'))
        search = '%s\n\n%s\n\n%s' % (names, iditems, titleitems)
        search_results.append(search)
    return search_results
Exemplo n.º 16
0
    def getVideoUrl(self, entry):
        std_headers = {
            "User-Agent": "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6",
            "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Accept-Language": "en-us,en;q=0.5",
        }

        VIDEO_FMT_PRIORITY_MAP = {"18": 4, "35": 5, "34": 6}  # MP4 360p  # FLV 480p  # FLV 360p

        if int(config.plugins.yttrailer.best_resolution.value) <= 1:
            VIDEO_FMT_PRIORITY_MAP["38"] = 1  # MP4 Original (HD)
            VIDEO_FMT_PRIORITY_MAP["22"] = 3  # MP4 720p (HD)

            if int(config.plugins.yttrailer.best_resolution.value) == 0:
                VIDEO_FMT_PRIORITY_MAP["37"] = 2  # MP4 1080p (HD)

        video_url = None
        video_id = str(self.getTubeId(entry))

        # Getting video webpage
        # URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
        watch_url = "http://www.youtube.com/watch?v=%s&gl=US&hl=en" % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            print "[YTTrailer] trying to find out if a HD Stream is available", watch_url
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket_error), err:
            print "[YTTrailer] Error: Unable to retrieve watchpage - Error code: ", str(err)
            return video_url
def search_tmbd(title):
    url = 'http://www.themoviedb.org/search?query=%s' % title
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    data = watchvideopage.read()
    search_results = []
    watchvideopage.close()
    if '<div class="search_results movie ">' in data:
        content_results = singleValue(
            data,
            '<div class="search_results movie ">(.*?)<div class="search_results collection hide">'
        )
        if content_results:
            iditems = re.compile(
                '<a id=".*?" class="result" href="(.*?)" title=".*?" alt=".*?">'
            ).findall(content_results)
            years = re.compile(
                '<span class="release_date"> (.*?) <span class=".*?"></span></span>'
            ).findall(content_results)
            directors = re.compile(
                '<span class="genres">(.*?)</span>').findall(content_results)
            images = re.compile(
                '<img class="poster lazyload" data-src="(.*?)" .*? alt=".*?">'
            ).findall(content_results)
            titleitems = re.compile(
                '<a id=".*?" class="result" href=".*?" title="(.*?)" alt=".*?">'
            ).findall(content_results)
            for titleitem in titleitems:
                search_results.append(titleitem)

            d = 0
            for director in directors:
                if d < len(directors):
                    search_results[
                        d] = search_results[d] + '\n year: ' + years[
                            d] + '\n \xd1\x80\xd0\xb5\xd0\xb6. ' + director
                d += 1

            l = 0
            for iditem in iditems:
                if l < len(iditems):
                    search_results[
                        l] = search_results[l] + '\n' + 'id:' + iditem + 'end'
                l += 1

            e = 0
            for image in images:
                if e < len(images):
                    search_results[e] = search_results[
                        e] + '\n' + 'image:' + image + 'ends'
                e += 1

    return search_results
Exemplo n.º 18
0
def wgetUrlRefer(target, refer):
	req = Request(target)
	req.add_header('Referer', refer)
	try:
		r = urlopen2(req)
		outtxt = r.read()
	except:
		outtxt = ''
	return outtxt
Exemplo n.º 19
0
class VuPlayerLauncher:
    QUALITY_CODE = {
        '5': 'FLV 224p',
        '6': 'FLV 270p',
        '34': 'FLV 360p',
        '35': 'FLV 480p',
        '18': 'MP4 360p',
        '22': 'MP4 720p',
        '37': 'MP4 1080p',
        '38': 'MP4 2304p',
        '83': 'MP4-3D 240p',
        '82': 'MP4-3D 360p',
        '85': 'MP4-3D 520p',
        '84': 'MP4-3D 720p',
        '43': 'WebM 360p',
        '44': 'WebM 480p',
        '45': 'WebM 720p',
        '46': 'WebM 1080p',
        '100': 'WebM-3D 360p',
        '101': 'WebM-3D 480p',
        '102': 'WebM-3D 720p',
        '13': '3GP 0.5',
        '17': '3GP 2.0'
    }

    def getVideoUrl(self, video_id):
        video_url = None

        if video_id is None or video_id == "":
            return video_url

        # Getting video webpage
        watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            #print "trying to find out if a HD Stream is available",watch_url
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket.error), err:
            print "Error: Unable to retrieve watchpage - Error code: ", str(
                err)
            return video_url

        # Get video info
        for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
            info_url = (
                'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
                % (video_id, el))
            request = Request(info_url, None, std_headers)
            try:
                infopage = urlopen2(request).read()
                videoinfo = parse_qs(infopage)
                if ('url_encoded_fmt_stream_map'
                        or 'fmt_url_map') in videoinfo:
                    break
            except (URLError, HTTPException, socket.error), err:
                print "Error: unable to download video infopage", str(err)
                return video_url
Exemplo n.º 20
0
def wgetUrl(target):
	std_headers = {
		'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
		'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
		'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
		'Accept-Language': 'en-us,en;q=0.5',
	}
	outtxt = Request(target, None, std_headers)
	try:
		outtxt = urlopen2(target, timeout = 5).read()
	except (URLError, HTTPException, socket.error):
		return ''
	return outtxt
Exemplo n.º 21
0
def poster_save(id):
    url2 = 'http://www.kinopoisk.ru%s' % id
    watchrequest2 = Request(url2, None, std_headers)
    try:
        watchvideopage2 = urlopen2(watchrequest2)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data2 = watchvideopage2.read().decode('cp1251').encode('utf-8')
    coveritem = ''
    coveritem = singleValue(data2, '<img style=".*?" id="image" src="(.*?)".*?/>')
    watchvideopage2.close()
    return coveritem
def poster_save(id):
    url2 = 'http://www.kinopoisk.ru%s' % id
    watchrequest2 = Request(url2, None, std_headers)
    try:
        watchvideopage2 = urlopen2(watchrequest2)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data2 = watchvideopage2.read().decode('cp1251').encode('utf-8')
    coveritem = ''
    coveritem = singleValue(data2, '<img style=".*?" id="image" src="(.*?)".*?/>')
    watchvideopage2.close()
    return coveritem
Exemplo n.º 23
0
def wgetUrl(target):
	std_headers = {
		'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
		'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
		'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
		'Accept-Language': 'en-us,en;q=0.5',
	}
	outtxt = Request(target, None, std_headers)
	try:
		outtxt = urlopen2(target, timeout = 5).read()
	except (URLError, HTTPException, socket.error):
		return ''
	return outtxt
Exemplo n.º 24
0
	def getVideoUrl(self, video_id):
		video_url = None

		if video_id is None or video_id == "":
			return video_url

		# Getting video webpage
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			#print "trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
Exemplo n.º 25
0
	def getVideoUrl(self, video_id):
		video_url = None

		if video_id is None or video_id == "":
			return video_url

		# Getting video webpage
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			#print "trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
Exemplo n.º 26
0
def postto(url, datadict, headers={}, decodec='gbk'):
    params = urlencode(datadict)
    _logger.info('Post %s to %s, headers %s', params, url, headers)
    try:
        req = Request(url=url, data=params)
        for k,v in headers.items():
            req.add_header(k,v)
        con = urlopen2(req)
        if con:
            _logger.info("Hit %s %d", str(con), con.getcode())
            data = con.read(-1)
            return data.decode(decodec)
        else: 
            _logger.error("No data returned.")
            return None

    except Exception, err:
        _logger.error(str(err))
Exemplo n.º 27
0
 def youtube(self, url, videoPrio=2):
     # this part is from mtube plugin
     print "got url: " + str(url)
     if videoPrio == 0:
         VIDEO_FMT_PRIORITY_MAP = {
             '38': 6,  #MP4 Original (HD)
             '37': 5,  #MP4 1080p (HD)
             '22': 4,  #MP4 720p (HD)
             '35': 2,  #FLV 480p
             '18': 1,  #MP4 360p
             '34': 3,  #FLV 360p
         }
     elif videoPrio == 1:
         VIDEO_FMT_PRIORITY_MAP = {
             '38': 6,  #MP4 Original (HD)
             '37': 5,  #MP4 1080p (HD)
             '22': 1,  #MP4 720p (HD)
             '35': 3,  #FLV 480p
             '18': 2,  #MP4 360p
             '34': 4,  #FLV 360p
         }
     else:
         VIDEO_FMT_PRIORITY_MAP = {
             '38': 3,  #MP4 Original (HD)
             '37': 1,  #MP4 1080p (HD)
             '22': 2,  #MP4 720p (HD)
             '35': 5,  #FLV 480p
             '18': 4,  #MP4 360p
             '34': 6,  #FLV 360p
         }
     video_url = None
     url = url.replace('/embed/', '/watch?v=')
     id = re.findall('watch.v=(.*\D)', url, re.S)
     video_id = id[0]
     # Getting video webpage
     #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
     watch_url = 'http://www.youtube.com/watch?v=%s&gl=DE&hl=de' % video_id
     watchrequest = Request(watch_url, None, std_headers)
     try:
         print "[youtubeUrl] trying to find out if a HD Stream is available", watch_url
         watchvideopage = urlopen2(watchrequest).read()
     except (URLError, HTTPException, socket.error), err:
         return "Error: Unable to retrieve watchpage - Error code: %s" % str(
             err)
Exemplo n.º 28
0
	def youtube(self, url, videoPrio=2):
		# this part is from mtube plugin
		print "got url: " + str(url)
		if videoPrio == 0:
			VIDEO_FMT_PRIORITY_MAP = {
				'38' : 6, #MP4 Original (HD)
				'37' : 5, #MP4 1080p (HD)
				'22' : 4, #MP4 720p (HD)
				'35' : 2, #FLV 480p
				'18' : 1, #MP4 360p
				'34' : 3, #FLV 360p
			}
		elif videoPrio == 1:
			VIDEO_FMT_PRIORITY_MAP = {
				'38' : 6, #MP4 Original (HD)
				'37' : 5, #MP4 1080p (HD)
				'22' : 1, #MP4 720p (HD)
				'35' : 3, #FLV 480p
				'18' : 2, #MP4 360p
				'34' : 4, #FLV 360p
			}
		else:
			VIDEO_FMT_PRIORITY_MAP = {
				'38' : 3, #MP4 Original (HD)
				'37' : 1, #MP4 1080p (HD)
				'22' : 2, #MP4 720p (HD)
				'35' : 5, #FLV 480p
				'18' : 4, #MP4 360p
				'34' : 6, #FLV 360p
			}
		video_url = None
		url = url.replace('/embed/', '/watch?v=')
		id = re.findall('watch.v=(.*\D)', url, re.S)
		video_id = id[0]
		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=DE&hl=de' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[youtubeUrl] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			return "Error: Unable to retrieve watchpage - Error code: %s" % str(err)
def search_comets(id):
    url = 'http://www.kinopoisk.ru/level/1/film/' + id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find('<p class="more_random">'):content.find('\xd0\x94\xd0\xbb\xd1\x8f \xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd1\x87\xd1\x82\xd0\xbe\xd0\xb1\xd1\x8b \xd0\xb4\xd0\xbe\xd0\xb1\xd0\xb0\xd0\xb2\xd0\xb8\xd1\x82\xd1\x8c \xd1\x80\xd0\xb5\xd1\x86\xd0\xb5\xd0\xbd\xd0\xb7\xd0\xb8\xd1\x8e \xd0\xbd\xd0\xb0 \xd1\x84\xd0\xb8\xd0\xbb\xd1\x8c\xd0\xbc, \xd0\xbd\xd0\xb5\xd0\xbe\xd0\xb1\xd1\x85\xd0\xbe\xd0\xb4\xd0\xb8\xd0\xbc\xd0\xbe')]
    if content_results:
        results = CrewRoleList2(content_results)
        names = normilize_string(singleValue(results, '<p class="profile_name"><s></s><a href=".*?" itemprop="name">(.*?)</a></p>'))
        titleitems = normilize_string(singleValue(results, '<span class="_reachbanner_" itemprop="reviewBody">(.*?)</span></p> </div>'))
        iditems = normilize_string(singleValue(results, '<p class="sub_title" id=".*?">(.*?)</p>'))
        search = '%s\n\n%s\n\n%s' % (names, iditems, titleitems)
        search_results.append(search)
    return search_results
def search_tmbd(title):
    url = 'http://www.themoviedb.org/search?query=%s' % title
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    watchvideopage.close()
    if '<div class="search_results movie ">' in data:
        content_results = singleValue(data, '<div class="search_results movie ">(.*?)<div class="search_results collection hide">')
        if content_results:
            iditems = re.compile('<a id=".*?" class="result" href="(.*?)" title=".*?" alt=".*?">').findall(content_results)
            years = re.compile('<span class="release_date"> (.*?) <span class=".*?"></span></span>').findall(content_results)
            directors = re.compile('<span class="genres">(.*?)</span>').findall(content_results)
            images = re.compile('<img class="poster lazyload" data-src="(.*?)" .*? alt=".*?">').findall(content_results)
            titleitems = re.compile('<a id=".*?" class="result" href=".*?" title="(.*?)" alt=".*?">').findall(content_results)
            for titleitem in titleitems:
                search_results.append(titleitem)

            d = 0
            for director in directors:
                if d < len(directors):
                    search_results[d] = search_results[d] + '\n year: ' + years[d] + '\n \xd1\x80\xd0\xb5\xd0\xb6. ' + director
                d += 1

            l = 0
            for iditem in iditems:
                if l < len(iditems):
                    search_results[l] = search_results[l] + '\n' + 'id:' + iditem + 'end'
                l += 1

            e = 0
            for image in images:
                if e < len(images):
                    search_results[e] = search_results[e] + '\n' + 'image:' + image + 'ends'
                e += 1

    return search_results
Exemplo n.º 31
0
def search_postermp3(url):
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    cover = ''
    watchvideopage.close()
    if 'src="' in data:
        coveritems = re.compile('src="(.*?)"').findall(data)
        for coveritem in coveritems:
            if 'http://' in coveritem:
                if '&imgurl=' in coveritem:
                    search_results.append(singleValue(coveritem, '&imgurl=(.*?)&w='))
                else:
                    search_results.append(coveritem)

    return search_results
def search_postermp3(url):
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    cover = ''
    watchvideopage.close()
    if 'src="' in data:
        coveritems = re.compile('src="(.*?)"').findall(data)
        for coveritem in coveritems:
            if 'http://' in coveritem:
                if '&imgurl=' in coveritem:
                    search_results.append(singleValue(coveritem, '&imgurl=(.*?)&w='))
                else:
                    search_results.append(coveritem)

    return search_results
Exemplo n.º 33
0
	def getVideoUrl(self):
		VIDEO_FMT_PRIORITY_MAP = {
			'38' : 1, #MP4 Original (HD)
			'37' : 2, #MP4 1080p (HD)
			'22' : 3, #MP4 720p (HD)
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}
		video_url = None
		video_id = str(self.getTubeId())

		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[MyTube] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
Exemplo n.º 34
0
def send_captcha(key, fobj):
    items = []
    items.append(MultipartParam(name='key', value=key))
    items.append(MultipartParam(name='method', value='post'))
    items.append(MultipartParam(name='file', filename='captcha.jpg',
                                fileobj=fobj))

    data, headers = multipart_encode(items)
    req = Request('http://antigate.com/in.php', data, headers)
    res = urlopen2(req)
    if res.code == 200:
        chunks = res.read().split('|')
        if len(chunks) == 2:
            return int(chunks[1])
        else:
            msg = chunks[0]
            raise CaptchaError(msg)
    else:
        msg = '%s %s' % (res.code, res.msg)
        raise CaptchaError(msg)
    print(res.info())
    return res.read()
Exemplo n.º 35
0
def __get_tick_quotes_finam__(symbol, start_date, end_date, verbose=False):
    start_date = datetime.strptime(start_date, "%Y%m%d").date()
    end_date = datetime.strptime(end_date, "%Y%m%d").date()
    delta = end_date - start_date
    data = DataFrame()
    for i in range(delta.days + 1):
        day = timedelta(i)
        url = __get_url__(symbol, periods["tick"], start_date + day, start_date + day, verbose)
        req = Request(url)
        req.add_header("Referer", "http://www.finam.ru/analysis/profile0000300007/default.asp")
        r = urlopen2(req)
        try:
            tmp_data = read_csv(r, index_col=0, parse_dates={"index": [0, 1]}, sep=";").sort_index()
            if data.empty:
                data = tmp_data
            else:
                data = data.append(tmp_data)
        except Exception:
            print ("error on data downloading {} {}".format(symbol, start_date + day))

    data.columns = [symbol + "." + i for i in ["Last", "Vol", "Id"]]
    return data
Exemplo n.º 36
0
def send_captcha(key, fobj):
    items = []
    items.append(MultipartParam(name='key', value=key))
    items.append(MultipartParam(name='method', value='post'))
    items.append(
        MultipartParam(name='file', filename='captcha.jpg', fileobj=fobj))

    data, headers = multipart_encode(items)
    req = Request('http://antigate.com/in.php', data, headers)
    res = urlopen2(req)
    if res.code == 200:
        chunks = res.read().split('|')
        if len(chunks) == 2:
            return int(chunks[1])
        else:
            msg = chunks[0]
            raise CaptchaError(msg)
    else:
        msg = '%s %s' % (res.code, res.msg)
        raise CaptchaError(msg)
    print(res.info())
    return res.read()
Exemplo n.º 37
0
	def getVideoUrl(self):
		VIDEO_FMT_PRIORITY_MAP = {
			'38' : 1, #MP4 Original (HD)
			'37' : 2, #MP4 1080p (HD)
			'22' : 3, #MP4 720p (HD)
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}
		video_url = None
		video_id = str(self.getTubeId())

		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[MyTube] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
Exemplo n.º 38
0
import distutils.spawn
import hashlib
import os
import sys
import tarfile
import shutil

try:
    from urllib.request import urlopen
except ImportError:
    # We are in python2
    from urllib2 import urlopen as urlopen2
    from contextlib import closing
    urlopen = lambda url: closing(urlopen2(url))

with open('src/snapshots.txt') as f:
    lines = f.readlines()

date = lines[0]
linux32 = lines[1]
linux64 = lines[2]
mac32 = lines[3]
mac64 = lines[4]
win32 = lines[5]
win64 = lines[6]
triple = sys.argv[1]

ts = triple.split('-')
arch = ts[0]
if len(ts) == 2:
    vendor = 'unknown'
	def getWeatherThread(self):
		global g_updateRunning
		id = ""
		name = ""
		temp = ""
		temp_max = ""
		temp_min = ""
		if config.plugins.MetrixWeather.weatherservice.value == "MSN":
			text = "MetrixHDWeatherStandalone lookup for City " + str(self.cityname)
		else:
			text = "MetrixHDWeatherStandalone lookup for ID " + str(self.woeid)
		if self.check:
			self.writeCheckFile(text)
		print text

		if config.plugins.MetrixWeather.weatherservice.value == "MSN":
			units = 'C'
			if config.plugins.MetrixWeather.tempUnit.value == "Fahrenheit":
				units ='F'
			language = config.osd.language.value.replace('_', '-')
			if language == 'en-EN':
				language = 'en-US'
			city="%s" % self.cityname
			feedurl = "http://weather.service.msn.com/data.aspx?weadegreetype=%s&culture=%s&weasearchstr=%s&src=outlook" % (units,language,urllib2_quote(city))
			msnrequest = Request(feedurl, None, std_headers)
			try:
				msnpage = urlopen2(msnrequest)
			except (URLError) as err:
				self.errorCallback(message = str(err))
				return
			g_updateRunning = False
			try:
				content = msnpage.read()
				msnpage.close()
				dom = parseString(content)
				currentWeather = dom.getElementsByTagName('weather')[0]
				titlemy = currentWeather.getAttributeNode('weatherlocationname')
				config.plugins.MetrixWeather.currentLocation.value = titlemy.nodeValue
				name = titlemy.nodeValue
				idmy =  currentWeather.getAttributeNode('weatherlocationcode')
				id = idmy.nodeValue
				currentWeather = dom.getElementsByTagName('current')[0]
				currentWeatherCode = currentWeather.getAttributeNode('skycode')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.currentWeatherCode.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.currentWeatherCode.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('temperature')
				temp = currentWeatherTemp.nodeValue
				config.plugins.MetrixWeather.currentWeatherTemp.value = currentWeatherTemp.nodeValue
				currenthumidity = currentWeather.getAttributeNode('humidity')
				config.plugins.MetrixWeather.currentWeatherhumidity.value = currenthumidity.nodeValue
				currentwinddisplay = currentWeather.getAttributeNode('winddisplay')
				config.plugins.MetrixWeather.currentWeatherwinddisplay.value = currentwinddisplay.nodeValue
				currentwindspeed = currentWeather.getAttributeNode('windspeed')
				config.plugins.MetrixWeather.currentWeatherwindspeed.value = currentwindspeed.nodeValue
				currentshortday = currentWeather.getAttributeNode('shortday')
				config.plugins.MetrixWeather.currentWeathershortday.value = currentshortday.nodeValue
				currentday = currentWeather.getAttributeNode('day')
				config.plugins.MetrixWeather.currentWeatherday.value = currentday.nodeValue
				currentdate = currentWeather.getAttributeNode('date')
				config.plugins.MetrixWeather.currentWeatherdate.value = currentdate.nodeValue
				currentfeelslike = currentWeather.getAttributeNode('feelslike')
				config.plugins.MetrixWeather.currentWeatherfeelslike.value = currentfeelslike.nodeValue
				currentobservationtime = currentWeather.getAttributeNode('observationtime')
				config.plugins.MetrixWeather.currentWeatherobservationtime.value = currentobservationtime.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytext')
				config.plugins.MetrixWeather.currentWeatherText.value = currentWeatherText.nodeValue
				n = 1
				currentWeather = dom.getElementsByTagName('forecast')[n]
				currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.forecastTodayCode.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.forecastTodayCode.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('high')
				temp_max  = currentWeatherTemp.nodeValue
				config.plugins.MetrixWeather.forecastTodayTempMax.value = currentWeatherTemp.nodeValue
				currentWeatherTemp = currentWeather.getAttributeNode('low')
				temp_min = currentWeatherTemp.nodeValue
				config.plugins.MetrixWeather.forecastTodayTempMin.value = currentWeatherTemp.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytextday')
				config.plugins.MetrixWeather.forecastTodayText.value = currentWeatherText.nodeValue
				currentWeather = dom.getElementsByTagName('forecast')[n + 1]
				currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.forecastTomorrowCode.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.forecastTomorrowCode.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('high')
				config.plugins.MetrixWeather.forecastTomorrowTempMax.value = currentWeatherTemp.nodeValue
				currentWeatherTemp = currentWeather.getAttributeNode('low')
				config.plugins.MetrixWeather.forecastTomorrowTempMin.value = currentWeatherTemp.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytextday')
				config.plugins.MetrixWeather.forecastTomorrowText.value = currentWeatherText.nodeValue
				currentWeatherdate = currentWeather.getAttributeNode('date')
				config.plugins.MetrixWeather.forecastTomorrowdate.value = currentWeatherdate.nodeValue
				currentWeatherday = currentWeather.getAttributeNode('day')
				config.plugins.MetrixWeather.forecastTomorrowday.value = currentWeatherday.nodeValue
				currentWeathershortday = currentWeather.getAttributeNode('shortday')
				config.plugins.MetrixWeather.forecastTomorrowshortday.value = currentWeathershortday.nodeValue

				currentWeather = dom.getElementsByTagName('forecast')[n + 2]
				currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.forecastTomorrowCode2.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.forecastTomorrowCode2.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('high')
				config.plugins.MetrixWeather.forecastTomorrowTempMax2.value = currentWeatherTemp.nodeValue
				currentWeatherTemp = currentWeather.getAttributeNode('low')
				config.plugins.MetrixWeather.forecastTomorrowTempMin2.value = currentWeatherTemp.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytextday')
				config.plugins.MetrixWeather.forecastTomorrowText2.value = currentWeatherText.nodeValue
				currentWeatherdate = currentWeather.getAttributeNode('date')
				config.plugins.MetrixWeather.forecastTomorrowdate2.value = currentWeatherdate.nodeValue
				currentWeatherday = currentWeather.getAttributeNode('day')
				config.plugins.MetrixWeather.forecastTomorrowday2.value = currentWeatherday.nodeValue
				currentWeathershortday = currentWeather.getAttributeNode('shortday')
				config.plugins.MetrixWeather.forecastTomorrowshortday2.value = currentWeathershortday.nodeValue

				currentWeather = dom.getElementsByTagName('forecast')[n + 3]
				currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.forecastTomorrowCode3.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.forecastTomorrowCode3.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('high')
				config.plugins.MetrixWeather.forecastTomorrowTempMax3.value = currentWeatherTemp.nodeValue
				currentWeatherTemp = currentWeather.getAttributeNode('low')
				config.plugins.MetrixWeather.forecastTomorrowTempMin3.value = currentWeatherTemp.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytextday')
				config.plugins.MetrixWeather.forecastTomorrowText3.value = currentWeatherText.nodeValue
				currentWeatherdate = currentWeather.getAttributeNode('date')
				config.plugins.MetrixWeather.forecastTomorrowdate3.value = currentWeatherdate.nodeValue
				currentWeatherday = currentWeather.getAttributeNode('day')
				config.plugins.MetrixWeather.forecastTomorrowday3.value = currentWeatherday.nodeValue
				currentWeathershortday = currentWeather.getAttributeNode('shortday')
				config.plugins.MetrixWeather.forecastTomorrowshortday3.value = currentWeathershortday.nodeValue
				if self.check:
					text = "%s|%s|%s°|%s°|%s°" %(id,name,temp,temp_max,temp_min)
					self.writeCheckFile(text)
					return
			except IndexError, err:
				self.errorCallback(message = str(err))
				return
			self.setWeatherDataValid(3)
Exemplo n.º 40
0
class YTTrailer:
	def __init__(self, session):
		self.session = session
		self.l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT)

	def showTrailer(self, eventname):
		if eventname:
			feeds = self.getYTFeeds(eventname, 1)
			if feeds and len(feeds.entry) >= 1:
				ref = self.setServiceReference(feeds.entry[0])
				if ref:
					self.session.open(TrailerPlayer, ref)

	def getYTFeeds(self, eventname, max_results):
		yt_service = gdata.youtube.service.YouTubeService()
		# developer key and client id taken from mytube-plugin with permission from acid_burn.
		yt_service.developer_key = 'AI39si4AjyvU8GoJGncYzmqMCwelUnqjEMWTFCcUtK-VUzvWygvwPO-sadNwW5tNj9DDCHju3nnJEPvFy4WZZ6hzFYCx8rJ6Mw'
		yt_service.client_id = 'ytapi-dream-MyTubePlayer-i0kqrebg-0'
		query = gdata.youtube.service.YouTubeVideoQuery()
		if int(config.plugins.yttrailer.best_resolution.value) <= 1:
			shd = "HD"
		else:
			shd = ""
		query.vq = "%s %s Trailer %s" % (eventname, shd, config.plugins.yttrailer.ext_descr.value)
		query.max_results = max_results
		try:
			feeds = yt_service.YouTubeQuery(query)
		except gaierror:
			feeds = None
		return feeds

	def setServiceReference(self, entry):
		url = self.getVideoUrl(entry)
		if url:
			ref = eServiceReference(4097,0,url)
			ref.setName(entry.media.title.text)
		else:
			ref = None
		return ref

	def getTubeId(self, entry):
		ret = None
		if entry.media.player:
			split = entry.media.player.url.split("=")
			ret = split.pop()
			if ret.startswith('youtube_gdata'):
				tmpval=split.pop()
				if tmpval.endswith("&feature"):
					tmp = tmpval.split("&")
					ret = tmp.pop(0)
		return ret

	def getVideoUrl(self, entry):
		std_headers = {
			'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
			'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
			'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
			'Accept-Language': 'en-us,en;q=0.5',
		}

		VIDEO_FMT_PRIORITY_MAP = {
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}

		if int(config.plugins.yttrailer.best_resolution.value) <= 1:
			VIDEO_FMT_PRIORITY_MAP["38"] = 1 #MP4 Original (HD)
			VIDEO_FMT_PRIORITY_MAP["22"] = 3 #MP4 720p (HD)

			if int(config.plugins.yttrailer.best_resolution.value) == 0:
				VIDEO_FMT_PRIORITY_MAP["37"] = 2 #MP4 1080p (HD)

		video_url = None
		video_id = str(self.getTubeId(entry))

		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[YTTrailer] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket_error), err:
			print "[YTTrailer] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url

		# Get video info
		for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
			info_url = ('http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (video_id, el))
			request = Request(info_url, None, std_headers)
			try:
				infopage = urlopen2(request).read()
				videoinfo = parse_qs(infopage)
				if ('url_encoded_fmt_stream_map' or 'fmt_url_map') in videoinfo:
					break
			except (URLError, HTTPException, socket_error), err:
				print "[YTTrailer] Error: unable to download video infopage",str(err)
				return video_url
def search_title(title):
    yearitem = ''
    titleitem = ''
    iditem = ''
    genres = ''
    search = ''
    title = title.replace(' ', '%20').decode('utf8')
    encoded_args = urllib.quote(title.encode('cp1251'))
    url = 'http://www.kinopoisk.ru/index.php?first=no&what=&kp_query=%s' % encoded_args
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find('\xd0\xa1\xd0\xba\xd0\xbe\xd1\x80\xd0\xb5\xd0\xb5 \xd0\xb2\xd1\x81\xd0\xb5\xd0\xb3\xd0\xbe, \xd0\xb2\xd1\x8b \xd0\xb8\xd1\x89\xd0\xb5\xd1\x82\xd0\xb5:'):content.find('search_results search_results_last')]
    if content_results:
        results = CrewRoleList(content_results)
        yearitems = re.compile('<span class="year">(.*?)</span>').findall(content_results)
        titleitems = re.compile('<p class="name"><a href="/film/.*?/sr/1/" .*? data-type=".*?">(.*?)</a> <span class="year">.*?</span></p>').findall(content_results)
        iditems = re.compile('<p class="name"><a href="/film/.*?/sr/1/" .*? data-id="(.*?)" data-type=".*?">.*?</a> <span class="year">.*?</span></p>').findall(content_results)
        genres = re.compile('<span class="genres">(.*?)</span>').findall(results)     
        for titleitem in titleitems:
            search_results.append(normilize_string(titleitem))

        i = 0
        for yearitem in yearitems:
            if i < len(yearitems):
                search_results[i] = search_results[i] + '(' + normilize_string(yearitem) + ' \xd0\xb3\xd0\xbe\xd0\xb4),'
            i += 1

        l = 0
        for iditem in iditems:
            if l < len(iditems):
                search_results[l] = search_results[l] + '\n genres:' + genres[l] + 'end' + '\n\n' + 'id:' + iditem.strip() + 'end'
            l += 1

    else:
        try:
            genres = ','.join(multiValue(content, '<tr><td class="type">\xd0\xb6\xd0\xb0\xd0\xbd\xd1\x80</td>(.*?)</tr>', '<a href=".*?>(.*?)</a>'))
            genres = '\n genres:' + genres + 'end'
        except:
            genres = '\n genres:end'

        try:
            titleitem = normilize_string(singleValue(content, '<h1 class="moviename-big" itemprop="name">(.*?)</h1>'))
        except:
            titleitem = ''

        try:
            yearitem = ','.join(multiValue(content, '<td class="type">\xd0\xb3\xd0\xbe\xd0\xb4</td>(.*?)</div></td>', '<a href=".*?" title=".*?">(.*?)</a>'))
            yearitem = '(%s \xd0\xb3\xd0\xbe\xd0\xb4),' % yearitem
        except:
            yearitem = ''

        try:
            iditem = singleValue(content, '<link rel="canonical" href="http://www.kinopoisk.ru/film/(.*?)/" />')
            iditem = '\n\nid:%send' % iditem
        except:
            iditem = '\n\nid: end'

        search = '%s%s%s%s' % (titleitem,
         yearitem,
         genres,
         iditem)
        search_results.append(search)
    return search_results
def search_title2(title):
    yearitem = ''
    titleitem = ''
    iditem = ''
    rating = ''
    director = ''
    titleengle = ''
    countri = ''
    iditem = ''
    search = ''
    runtime = ''
    time = ''
    title = title.replace(' ', '%20').decode('utf8')
    encoded_args = urllib.quote(title.encode('cp1251'))
    url = 'http://www.kinopoisk.ru/index.php?first=no&what=&kp_query=%s' % encoded_args
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find('\xd0\xa1\xd0\xba\xd0\xbe\xd1\x80\xd0\xb5\xd0\xb5 \xd0\xb2\xd1\x81\xd0\xb5\xd0\xb3\xd0\xbe, \xd0\xb2\xd1\x8b \xd0\xb8\xd1\x89\xd0\xb5\xd1\x82\xd0\xb5:'):content.find('search_results search_results_last')]
    if content_results:
        titleitems = re.compile('<p class="name"><a href="/level/1/film/.*?/sr/1/" .*? data-type=".*?">(.*?)</a> <span class="year">.*?</span></p>').findall(content_results)
        titleengles = re.compile('<span class="gray">(.*?)</span>').findall(content_results)
        directors = re.compile('<span class="gray">.*? <i class="director">.*? <a class=".*?" .*? data-type=".*?">(.*?)</a>').findall(content_results)
        countris = re.compile('<span class="gray">(.*?) <i class="director">.*? <a class=".*?" .*? data-type=".*?">.*?</a>').findall(content_results)
        iditems = re.compile('<p class="name"><a href="/level/1/film/(.*?)/sr/1/" .*? data-type="film">.*?</a> <span class="year">.*?</span></p>').findall(content_results)
        ratings = re.compile('<div class="rating.*?>(.*?)</div>').findall(content_results)
        for titleitem in titleitems:
            search_results.append(normilize_string(titleitem.replace('</a>', '').replace(' <span class="year">', '(').replace('</span>', ' \xd0\xb3\xd0\xbe\xd0\xb4),').replace('</p>', '')))

        k = 0
        for titleengle in titleengles:
            if titleengle == '':
                titleengle = '\xd0\x9d\xd0\xb5\xd1\x82 \xd0\xbd\xd0\xb0\xd0\xb7\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f'
            if k < len(titleengles):
                search_results[k] = search_results[k] + '\n' + normilize_string(titleengle)
            k += 1

        d = 0
        for director in directors:
            if d < len(directors):
                search_results[d] = search_results[d] + '\n' + countris[d] + '\xd1\x80\xd0\xb5\xd0\xb6. ' + normilize_string(director)
            d += 1

        l = 0
        for iditem in iditems:
            if l < len(iditems):
                search_results[l] = search_results[l] + '\n\n' + 'id:' + iditem + 'end'
            l += 1

        e = 0
        for rating in ratings:
            if e < len(ratings):
                search_results[e] = search_results[e] + '\n' + 'rating:' + rating + 'ends'
            e += 1

    else:
        try:
            titleitem = normilize_string(singleValue(content, '<h1 class="moviename-big" itemprop="name">(.*?)</h1>'))
        except:
            titleitem = ''

        try:
            director = normilize_string(','.join(multiValue(content, '<tr><td class="type">\xd1\x80\xd0\xb5\xd0\xb6\xd0\xb8\xd1\x81\xd1\x81\xd0\xb5\xd1\x80</td>(.*?)</tr>', '<a href=".*?>(.*?)</a>')))
            director = '\xd1\x80\xd0\xb5\xd0\xb6. %s' % director
        except:
            director = ''

        try:
            countri = ','.join(multiValue(content, '<td class="type">\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb0</td>(.*?)</tr>', '<a href=".*?>(.*?)</a>'))
            countri = '\n%s ,' % countri
        except:
            countri = ''

        try:
            time = string.split(singleValue(content, '<td class="time" id="runtime">(.*?)</td>'))
            runtime = time[0] + ' \xd0\xbc\xd0\xb8\xd0\xbd.'
        except:
            runtime = ''

        try:
            yearitem = ','.join(multiValue(content, '<td class="type">\xd0\xb3\xd0\xbe\xd0\xb4</td>(.*?)</div></td>', '<a href=".*?" title=".*?">(.*?)</a>'))
            yearitem = '(%s \xd0\xb3\xd0\xbe\xd0\xb4),' % yearitem
        except:
            yearitem = ''

        try:
            titleengle = normilize_string(singleValue(content, '<span itemprop="alternativeHeadline">(.*?)</span>'))
            titleengle = '\n%s, ' % titleengle
        except:
            titleengle = ''

        try:
            rating = singleValue(content, '<div class="div1"><meta itemprop="ratingValue" content="(.*?)" />')
            rating = '\nrating:%sends' % rating
        except:
            rating = '\nrating:  ends'

        try:
            iditem = singleValue(content, '<link rel="canonical" href="http://www.kinopoisk.ru/film/(.*?)/" />')
            iditem = '\n\nid:%send' % iditem
        except:
            iditem = '\n\nid: end'

        search = '%s%s%s%s%s%s%s%s' % (titleitem,
         yearitem,
         titleengle,
         runtime,
         countri,
         director,
         iditem,
         rating)
        search_results.append(search)
    return search_results
def search_data(id):
    url = 'http://www.kinopoisk.ru/level/1/film/' + id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    content_results = '%s' % data.replace('     ', '').replace('\n', '').replace('\t', '')
    watchvideopage.close()
    try:
        filmdata = {'title': '',
         'countries': '',
         'year': '',
         'directors': '',
         'cast': '',
         'genre': '',
         'user_rating': '',
         'rating_count': '',
         'movie_rating': '',
         'plot': '',
         'runtime': ''}
        try:
            filmdata['title'] = normilize_string(singleValue(data, '<title>(.*?)</title>'))
        except:
            filmdata['title'] = ''

        try:
            filmdata['directors'] = normilize_string(','.join(multiValue(data, '<tr><td class="type">\xd1\x80\xd0\xb5\xd0\xb6\xd0\xb8\xd1\x81\xd1\x81\xd0\xb5\xd1\x80</td>(.*?)</tr>', '<a href=".*?>(.*?)</a>')))
        except:
            filmdata['directors'] = ''

        try:
            filmdata['countries'] = ','.join(multiValue(data, '<td class="type">\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb0</td>(.*?)</tr>', '<a href=".*?>(.*?)</a>'))
        except:
            filmdata['countries'] = ''

        try:
            filmdata['year'] = ','.join(multiValue(data, '<td class="type">\xd0\xb3\xd0\xbe\xd0\xb4</td>(.*?)</div></td>', '<a href=".*?" title=".*?">(.*?)</a>'))
        except:
            filmdata['year'] = ''

        try:
            filmdata['genre'] = ','.join(multiValue(data, '<tr><td class="type">\xd0\xb6\xd0\xb0\xd0\xbd\xd1\x80</td>(.*?)</tr>', '<a href=".*?>(.*?)</a>'))
        except:
            filmdata['genre'] = ''

        try:
            filmdata['user_rating'] = singleValue(content_results, '<div class="div1"><meta itemprop="ratingValue" content="(.*?)" />')
        except:
            filmdata['user_rating'] = ''

        try:
            filmdata['rating_count'] = normilize_string(singleValue(data, '<span class="ratingCount">(.*?)</span>'))
        except:
            filmdata['rating_count'] = ''

        try:
            filmdata['plot'] = normilize_string(singleValue(data, '<tr><td colspan=3 style="padding: 10px.*?description">(.*?)</div></span>'))
        except:
            filmdata['plot'] = ''

        try:
            runtime = string.split(singleValue(data, '<td class="time" id="runtime">(.*?)</td>'))
            filmdata['runtime'] = runtime[0]
        except:
            filmdata['runtime'] = ''

        try:
            filmdata['cast'] = normilize_string(','.join(multiValue(data, '<h4>\xd0\x92 \xd0\xb3\xd0\xbb\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8b\xd1\x85 \xd1\x80\xd0\xbe\xd0\xbb\xd1\x8f\xd1\x85:</h4>(.*?)</a></li></ul>', '<a href="/name/.*?/">(.*?)</a>')))
        except:
            filmdata['cast'] = ''

        try:
            movierating = string.split(singleValue(data, '<td class="type">рейтинг MPAA</td>.*?<img src.*?alt=(.*?) border=0>'))
            if len(movierating) > 0:
                filmdata['movie_rating'] = movierating[1]
            else:
                filmdata['movie_rating'] = ''
        except:
            filmdata['movie_rating'] = ''

        return filmdata
    except:
        print_exception(traceback.format_exc())
Exemplo n.º 44
0
 def getWeather(self):
     # skip if weather-widget is already up to date
     tdelta = datetime.now() - datetime.strptime(
         config.plugins.MetrixWeather.lastUpdated.value,
         "%Y-%m-%d %H:%M:%S")
     if int(tdelta.seconds) < (
             config.plugins.MetrixWeather.refreshInterval.value *
             60):  ##### 1=60 for testing purpose #####
         return
     id = ""
     name = ""
     temp = ""
     temp_max = ""
     temp_min = ""
     cityname = config.plugins.MetrixWeather.weathercity.value
     print "[OMMetrixWeather] lookup for city " + str(cityname)
     language = config.osd.language.value.replace('_', '-')
     if language == 'en-EN':
         language = 'en-US'
     city = "%s" % cityname
     feedurl = "http://weather.service.msn.com/data.aspx?weadegreetype=%s&culture=%s&weasearchstr=%s&src=outlook" % (
         self.getTemp(), language, urllib2_quote(city))
     msnrequest = Request(feedurl, None, std_headers)
     try:
         msnpage = urlopen2(msnrequest)
     except (URLError) as err:
         print '[OMMetrixWeather] Error: Unable to retrieve page - Error code: ', str(
             err)
         config.plugins.MetrixWeather.lastUpdated.value = str(
             datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
         return
     content = msnpage.read()
     msnpage.close()
     dom = parseString(content)
     currentWeather = dom.getElementsByTagName('weather')[0]
     titlemy = currentWeather.getAttributeNode('weatherlocationname')
     config.plugins.MetrixWeather.currentLocation.value = titlemy.nodeValue
     name = titlemy.nodeValue
     idmy = currentWeather.getAttributeNode('weatherlocationcode')
     id = idmy.nodeValue
     currentWeather = dom.getElementsByTagName('current')[0]
     currentWeatherCode = currentWeather.getAttributeNode('skycode')
     config.plugins.MetrixWeather.currentWeatherCode.value = self.ConvertCondition(
         currentWeatherCode.nodeValue)
     currentWeatherTemp = currentWeather.getAttributeNode('temperature')
     temp = currentWeatherTemp.nodeValue
     config.plugins.MetrixWeather.currentWeatherTemp.value = currentWeatherTemp.nodeValue
     currentWeatherText = currentWeather.getAttributeNode('skytext')
     config.plugins.MetrixWeather.currentWeatherText.value = currentWeatherText.nodeValue
     n = 1
     currentWeather = dom.getElementsByTagName('forecast')[n]
     currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
     config.plugins.MetrixWeather.forecastTodayCode.value = self.ConvertCondition(
         currentWeatherCode.nodeValue)
     currentWeatherTemp = currentWeather.getAttributeNode('high')
     temp_max = currentWeatherTemp.nodeValue
     config.plugins.MetrixWeather.forecastTodayTempMax.value = currentWeatherTemp.nodeValue
     currentWeatherTemp = currentWeather.getAttributeNode('low')
     temp_min = currentWeatherTemp.nodeValue
     config.plugins.MetrixWeather.forecastTodayTempMin.value = currentWeatherTemp.nodeValue
     currentWeatherText = currentWeather.getAttributeNode('skytextday')
     config.plugins.MetrixWeather.forecastTodayText.value = currentWeatherText.nodeValue
     currentWeather = dom.getElementsByTagName('forecast')[n + 1]
     currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
     config.plugins.MetrixWeather.forecastTomorrowCode.value = self.ConvertCondition(
         currentWeatherCode.nodeValue)
     currentWeatherTemp = currentWeather.getAttributeNode('high')
     config.plugins.MetrixWeather.forecastTomorrowTempMax.value = currentWeatherTemp.nodeValue
     currentWeatherTemp = currentWeather.getAttributeNode('low')
     config.plugins.MetrixWeather.forecastTomorrowTempMin.value = currentWeatherTemp.nodeValue
     currentWeatherText = currentWeather.getAttributeNode('skytextday')
     config.plugins.MetrixWeather.forecastTomorrowText.value = currentWeatherText.nodeValue
     config.plugins.MetrixWeather.save()
     configfile.save()
def search_data(id):
    url = 'http://www.kinopoisk.ru/level/1/film/' + id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    content_results = '%s' % data
    watchvideopage.close()
    try:
        filmdata = {
            'title': '',
            'countries': '',
            'year': '',
            'directors': '',
            'cast': '',
            'genre': '',
            'user_rating': '',
            'rating_count': '',
            'movie_rating': '',
            'plot': '',
            'runtime': ''
        }
        try:
            filmdata['title'] = normilize_string(
                singleValue(data, '<title>(.*?)</title>'))
        except:
            filmdata['title'] = ''

        try:
            filmdata['directors'] = normilize_string(','.join(
                multiValue(
                    data,
                    '<tr><td class="type">\xd1\x80\xd0\xb5\xd0\xb6\xd0\xb8\xd1\x81\xd1\x81\xd0\xb5\xd1\x80</td>(.*?)</tr>',
                    '<a href=".*?>(.*?)</a>')))
        except:
            filmdata['directors'] = ''

        try:
            filmdata['countries'] = ','.join(
                multiValue(
                    data,
                    '<td class="type">\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb0</td>(.*?)</tr>',
                    '<a href=".*?>(.*?)</a>'))
        except:
            filmdata['countries'] = ''

        try:
            filmdata['year'] = ','.join(
                multiValue(
                    data,
                    '<td class="type">\xd0\xb3\xd0\xbe\xd0\xb4</td>(.*?)</div></td>',
                    '<a href=".*?" title=".*?">(.*?)</a>'))
        except:
            filmdata['year'] = ''

        try:
            filmdata['genre'] = ','.join(
                multiValue(
                    data,
                    '<tr><td class="type">\xd0\xb6\xd0\xb0\xd0\xbd\xd1\x80</td>(.*?)</tr>',
                    '<a href=".*?>(.*?)</a>'))
        except:
            filmdata['genre'] = ''

        try:
            filmdata['user_rating'] = singleValue(
                data,
                '<div class="div1"><meta itemprop="ratingValue" content="(.*?)" />'
            )
        except:
            filmdata['user_rating'] = ''

        try:
            filmdata['rating_count'] = normilize_string(
                singleValue(
                    data,
                    '<span class="ratingCount" itemprop="ratingCount">(.*?)</span>'
                ))
        except:
            filmdata['rating_count'] = ''

        try:
            filmdata['plot'] = normilize_string(
                singleValue(
                    data,
                    '<tr><td colspan=3 style="padding: 10px.*?description">(.*?)</div></span>'
                ))
        except:
            filmdata['plot'] = ''

        try:
            runtime = string.split(
                singleValue(data, '<td class="time" id="runtime">(.*?)</td>'))
            filmdata['runtime'] = runtime[0]
        except:
            filmdata['runtime'] = ''

        try:
            filmdata['cast'] = normilize_string(','.join(
                multiValue(
                    data,
                    '<h4>\xd0\x92 \xd0\xb3\xd0\xbb\xd0\xb0\xd0\xb2\xd0\xbd\xd1\x8b\xd1\x85 \xd1\x80\xd0\xbe\xd0\xbb\xd1\x8f\xd1\x85:</h4>(.*?)</a></li></ul>',
                    '<a href="/name/.*?/">(.*?)</a>')))
        except:
            filmdata['cast'] = ''

        try:
            movierating = string.split(
                singleValue(
                    data,
                    '<td class="type">\xd1\x80\xd0\xb5\xd0\xb9\xd1\x82\xd0\xb8\xd0\xbd\xd0\xb3 MPAA</td>.*?<img src.*?alt=(.*?) border=0>'
                ))
            if len(movierating) > 0:
                filmdata['movie_rating'] = movierating[1]
            else:
                filmdata['movie_rating'] = ''
        except:
            filmdata['movie_rating'] = ''

        return filmdata
    except:
        print_exception(traceback.format_exc())
def search_title2(title):
    yearitem = ''
    titleitem = ''
    iditem = ''
    rating = ''
    director = ''
    titleengle = ''
    countri = ''
    iditem = ''
    search = ''
    runtime = ''
    time = ''
    title = title.replace(' ', '%20').decode('utf8')
    print title
    url = 'http://www.kinopoisk.ru/index.php?first=no&what=&kp_query=' + title.encode(
        'cp1251')
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find(
        '\xd0\xa1\xd0\xba\xd0\xbe\xd1\x80\xd0\xb5\xd0\xb5 \xd0\xb2\xd1\x81\xd0\xb5\xd0\xb3\xd0\xbe, \xd0\xb2\xd1\x8b \xd0\xb8\xd1\x89\xd0\xb5\xd1\x82\xd0\xb5:'
    ):content.find('search_results search_results_last')]
    if content_results:
        titleitems = re.compile(
            '<p class="name"><a href="/level/1/film/.*?/sr/1/" .*? data-type=".*?">(.*?)</a> <span class="year">.*?</span></p>'
        ).findall(content_results)
        titleengles = re.compile('<span class="gray">(.*?)</span>').findall(
            content_results)
        directors = re.compile(
            '<span class="gray">.*? <i class="director">.*? <a class=".*?" .*? data-type=".*?">(.*?)</a>'
        ).findall(content_results)
        countris = re.compile(
            '<span class="gray">(.*?) <i class="director">.*? <a class=".*?" .*? data-type=".*?">.*?</a>'
        ).findall(content_results)
        iditems = re.compile(
            '<p class="name"><a href="/level/1/film/(.*?)/sr/1/" .*? data-type="film">.*?</a> <span class="year">.*?</span></p>'
        ).findall(content_results)
        ratings = re.compile('<div class="rating.*?>(.*?)</div>').findall(
            content_results)
        for titleitem in titleitems:
            search_results.append(
                normilize_string(
                    titleitem.replace('</a>', '').replace(
                        ' <span class="year">', '(').replace(
                            '</span>',
                            ' \xd0\xb3\xd0\xbe\xd0\xb4),').replace('</p>',
                                                                   '')))

        k = 0
        for titleengle in titleengles:
            if titleengle == '':
                titleengle = '\xd0\x9d\xd0\xb5\xd1\x82 \xd0\xbd\xd0\xb0\xd0\xb7\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f'
            if k < len(titleengles):
                search_results[k] = search_results[
                    k] + '\n' + normilize_string(titleengle)
            k += 1

        d = 0
        for director in directors:
            if d < len(directors):
                search_results[d] = search_results[d] + '\n' + countris[
                    d] + '\xd1\x80\xd0\xb5\xd0\xb6. ' + normilize_string(
                        director)
            d += 1

        l = 0
        for iditem in iditems:
            if l < len(iditems):
                search_results[
                    l] = search_results[l] + '\n\n' + 'id:' + iditem + 'end'
            l += 1

        e = 0
        for rating in ratings:
            if e < len(ratings):
                search_results[
                    e] = search_results[e] + '\n' + 'rating:' + rating + 'ends'
            e += 1

    else:
        try:
            titleitem = normilize_string(
                singleValue(
                    content,
                    '<h1 class="moviename-big" itemprop="name">(.*?)</h1>'))
        except:
            titleitem = ''

        try:
            director = normilize_string(','.join(
                multiValue(
                    content,
                    '<tr><td class="type">\xd1\x80\xd0\xb5\xd0\xb6\xd0\xb8\xd1\x81\xd1\x81\xd0\xb5\xd1\x80</td>(.*?)</tr>',
                    '<a href=".*?>(.*?)</a>')))
            director = '\xd1\x80\xd0\xb5\xd0\xb6. %s' % director
        except:
            director = ''

        try:
            countri = ','.join(
                multiValue(
                    content,
                    '<td class="type">\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb0</td>(.*?)</tr>',
                    '<a href=".*?>(.*?)</a>'))
            countri = '\n%s ,' % countri
        except:
            countri = ''

        try:
            time = string.split(
                singleValue(content,
                            '<td class="time" id="runtime">(.*?)</td>'))
            runtime = time[0] + ' \xd0\xbc\xd0\xb8\xd0\xbd.'
        except:
            runtime = ''

        try:
            yearitem = ','.join(
                multiValue(
                    content,
                    '<td class="type">\xd0\xb3\xd0\xbe\xd0\xb4</td>(.*?)</div></td>',
                    '<a href=".*?" title=".*?">(.*?)</a>'))
            yearitem = '(%s \xd0\xb3\xd0\xbe\xd0\xb4),' % yearitem
        except:
            yearitem = ''

        try:
            titleengle = normilize_string(
                singleValue(
                    content,
                    '<span itemprop="alternativeHeadline">(.*?)</span>'))
            titleengle = '\n%s, ' % titleengle
        except:
            titleengle = ''

        try:
            rating = singleValue(
                content,
                '<div class="div1"><meta itemprop="ratingValue" content="(.*?)" />'
            )
            rating = '\nrating:%sends' % rating
        except:
            rating = '\nrating:  ends'

        try:
            iditem = singleValue(
                content,
                '<link rel="canonical" href="http://www.kinopoisk.ru/film/(.*?)/" />'
            )
            iditem = '\n\nid:%send' % iditem
        except:
            iditem = '\n\nid: end'

        search = '%s%s%s%s%s%s%s%s' % (titleitem, yearitem, titleengle,
                                       runtime, countri, director, iditem,
                                       rating)
        search_results.append(search)
    return search_results
def search_title(title):
    yearitem = ''
    titleitem = ''
    iditem = ''
    genres = ''
    search = ''
    title = title.replace(' ', '%20').decode('utf8')
    print title
    url = 'http://www.kinopoisk.ru/index.php?first=no&what=&kp_query=' + title.encode(
        'cp1251')
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(
            err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find(
        '\xd0\xa1\xd0\xba\xd0\xbe\xd1\x80\xd0\xb5\xd0\xb5 \xd0\xb2\xd1\x81\xd0\xb5\xd0\xb3\xd0\xbe, \xd0\xb2\xd1\x8b \xd0\xb8\xd1\x89\xd0\xb5\xd1\x82\xd0\xb5:'
    ):content.find('search_results search_results_last')]
    if content_results:
        results = CrewRoleList(content_results)
        yearitems = re.compile(
            '<p class="name"><a href="/level/1/film/.*?/sr/1/" .*? data-type=".*?">.*?</a> <span class="year">(.*?)</span></p>'
        ).findall(content_results)
        titleitems = re.compile(
            '<p class="name"><a href="/level/1/film/.*?/sr/1/" .*? data-type=".*?">(.*?)</a> <span class="year">.*?</span></p>'
        ).findall(content_results)
        iditems = re.compile(
            '<p class="name"><a href="/level/1/film/(.*?)/sr/1/" .*? data-type=".*?">.*?</a> <span class="year">.*?</span></p>'
        ).findall(content_results)
        genres = re.compile('<span class="genres">(.*?)</span>').findall(
            results)
        for titleitem in titleitems:
            search_results.append(normilize_string(titleitem))

        i = 0
        for yearitem in yearitems:
            if i < len(yearitems):
                search_results[i] = search_results[i] + '(' + normilize_string(
                    yearitem) + ' \xd0\xb3\xd0\xbe\xd0\xb4),'
            i += 1

        l = 0
        for iditem in iditems:
            if l < len(iditems):
                search_results[l] = search_results[l] + '\n genres:' + genres[
                    l] + 'end' + '\n\n' + 'id:' + iditem + 'end'
            l += 1

    else:
        try:
            genres = ','.join(
                multiValue(
                    content,
                    '<tr><td class="type">\xd0\xb6\xd0\xb0\xd0\xbd\xd1\x80</td>(.*?)</tr>',
                    '<a href=".*?>(.*?)</a>'))
            genres = '\n genres:' + genres + 'end'
        except:
            genres = '\n genres:end'

        try:
            titleitem = normilize_string(
                singleValue(
                    content,
                    '<h1 class="moviename-big" itemprop="name">(.*?)</h1>'))
        except:
            titleitem = ''

        try:
            yearitem = ','.join(
                multiValue(
                    content,
                    '<td class="type">\xd0\xb3\xd0\xbe\xd0\xb4</td>(.*?)</div></td>',
                    '<a href=".*?" title=".*?">(.*?)</a>'))
            yearitem = '(%s \xd0\xb3\xd0\xbe\xd0\xb4),' % yearitem
        except:
            yearitem = ''

        try:
            iditem = singleValue(
                content,
                '<link rel="canonical" href="http://www.kinopoisk.ru/film/(.*?)/" />'
            )
            iditem = '\n\nid:%send' % iditem
        except:
            iditem = '\n\nid: end'

        search = '%s%s%s%s' % (titleitem, yearitem, genres, iditem)
        search_results.append(search)
    return search_results
    def getWeatherThread(self):
        global g_updateRunning
        id = ""
        name = ""
        temp = ""
        temp_max = ""
        temp_min = ""
        if config.plugins.MetrixWeather.weatherservice.value == "MSN":
            text = "MetrixHDWeatherStandalone lookup for City " + str(
                self.cityname)
        else:
            text = "MetrixHDWeatherStandalone lookup for ID " + str(self.woeid)
        if self.check:
            self.writeCheckFile(text)
        print text

        if config.plugins.MetrixWeather.weatherservice.value == "MSN":
            units = 'C'
            if config.plugins.MetrixWeather.tempUnit.value == "Fahrenheit":
                units = 'F'
            language = config.osd.language.value.replace('_', '-')
            if language == 'en-EN':
                language = 'en-US'
            city = "%s" % self.cityname
            feedurl = "http://weather.service.msn.com/data.aspx?weadegreetype=%s&culture=%s&weasearchstr=%s&src=outlook" % (
                units, language, urllib2_quote(city))
            msnrequest = Request(feedurl, None, std_headers)
            try:
                msnpage = urlopen2(msnrequest)
            except (URLError) as err:
                self.errorCallback(message=str(err))
                return
            g_updateRunning = False
            try:
                content = msnpage.read()
                msnpage.close()
                dom = parseString(content)
                currentWeather = dom.getElementsByTagName('weather')[0]
                titlemy = currentWeather.getAttributeNode(
                    'weatherlocationname')
                config.plugins.MetrixWeather.currentLocation.value = titlemy.nodeValue
                name = titlemy.nodeValue
                idmy = currentWeather.getAttributeNode('weatherlocationcode')
                id = idmy.nodeValue
                currentWeather = dom.getElementsByTagName('current')[0]
                currentWeatherCode = currentWeather.getAttributeNode('skycode')
                config.plugins.MetrixWeather.currentWeatherCode.value = self.ConvertConditionMSN(
                    currentWeatherCode.nodeValue)
                currentWeatherTemp = currentWeather.getAttributeNode(
                    'temperature')
                temp = currentWeatherTemp.nodeValue
                config.plugins.MetrixWeather.currentWeatherTemp.value = currentWeatherTemp.nodeValue
                currenthumidity = currentWeather.getAttributeNode('humidity')
                config.plugins.MetrixWeather.currentWeatherhumidity.value = currenthumidity.nodeValue
                currentwinddisplay = currentWeather.getAttributeNode(
                    'winddisplay')
                config.plugins.MetrixWeather.currentWeatherwinddisplay.value = currentwinddisplay.nodeValue
                currentwindspeed = currentWeather.getAttributeNode('windspeed')
                config.plugins.MetrixWeather.currentWeatherwindspeed.value = currentwindspeed.nodeValue
                currentshortday = currentWeather.getAttributeNode('shortday')
                config.plugins.MetrixWeather.currentWeathershortday.value = currentshortday.nodeValue
                currentday = currentWeather.getAttributeNode('day')
                config.plugins.MetrixWeather.currentWeatherday.value = currentday.nodeValue
                currentdate = currentWeather.getAttributeNode('date')
                config.plugins.MetrixWeather.currentWeatherdate.value = currentdate.nodeValue
                currentfeelslike = currentWeather.getAttributeNode('feelslike')
                config.plugins.MetrixWeather.currentWeatherfeelslike.value = currentfeelslike.nodeValue
                currentobservationtime = currentWeather.getAttributeNode(
                    'observationtime')
                config.plugins.MetrixWeather.currentWeatherobservationtime.value = currentobservationtime.nodeValue
                currentWeatherText = currentWeather.getAttributeNode('skytext')
                config.plugins.MetrixWeather.currentWeatherText.value = currentWeatherText.nodeValue
                n = 1
                currentWeather = dom.getElementsByTagName('forecast')[n]
                currentWeatherCode = currentWeather.getAttributeNode(
                    'skycodeday')
                config.plugins.MetrixWeather.forecastTodayCode.value = self.ConvertConditionMSN(
                    currentWeatherCode.nodeValue)
                currentWeatherTemp = currentWeather.getAttributeNode('high')
                temp_max = currentWeatherTemp.nodeValue
                config.plugins.MetrixWeather.forecastTodayTempMax.value = currentWeatherTemp.nodeValue
                currentWeatherTemp = currentWeather.getAttributeNode('low')
                temp_min = currentWeatherTemp.nodeValue
                config.plugins.MetrixWeather.forecastTodayTempMin.value = currentWeatherTemp.nodeValue
                currentWeatherText = currentWeather.getAttributeNode(
                    'skytextday')
                config.plugins.MetrixWeather.forecastTodayText.value = currentWeatherText.nodeValue
                currentWeather = dom.getElementsByTagName('forecast')[n + 1]
                currentWeatherCode = currentWeather.getAttributeNode(
                    'skycodeday')
                config.plugins.MetrixWeather.forecastTomorrowCode.value = self.ConvertConditionMSN(
                    currentWeatherCode.nodeValue)
                currentWeatherTemp = currentWeather.getAttributeNode('high')
                config.plugins.MetrixWeather.forecastTomorrowTempMax.value = currentWeatherTemp.nodeValue
                currentWeatherTemp = currentWeather.getAttributeNode('low')
                config.plugins.MetrixWeather.forecastTomorrowTempMin.value = currentWeatherTemp.nodeValue
                currentWeatherText = currentWeather.getAttributeNode(
                    'skytextday')
                config.plugins.MetrixWeather.forecastTomorrowText.value = currentWeatherText.nodeValue
                currentWeatherdate = currentWeather.getAttributeNode('date')
                config.plugins.MetrixWeather.forecastTomorrowdate.value = currentWeatherdate.nodeValue
                currentWeatherday = currentWeather.getAttributeNode('day')
                config.plugins.MetrixWeather.forecastTomorrowday.value = currentWeatherday.nodeValue
                currentWeathershortday = currentWeather.getAttributeNode(
                    'shortday')
                config.plugins.MetrixWeather.forecastTomorrowshortday.value = currentWeathershortday.nodeValue

                currentWeather = dom.getElementsByTagName('forecast')[n + 2]
                currentWeatherCode = currentWeather.getAttributeNode(
                    'skycodeday')
                config.plugins.MetrixWeather.forecastTomorrowCode2.value = self.ConvertConditionMSN(
                    currentWeatherCode.nodeValue)
                currentWeatherTemp = currentWeather.getAttributeNode('high')
                config.plugins.MetrixWeather.forecastTomorrowTempMax2.value = currentWeatherTemp.nodeValue
                currentWeatherTemp = currentWeather.getAttributeNode('low')
                config.plugins.MetrixWeather.forecastTomorrowTempMin2.value = currentWeatherTemp.nodeValue
                currentWeatherText = currentWeather.getAttributeNode(
                    'skytextday')
                config.plugins.MetrixWeather.forecastTomorrowText2.value = currentWeatherText.nodeValue
                currentWeatherdate = currentWeather.getAttributeNode('date')
                config.plugins.MetrixWeather.forecastTomorrowdate2.value = currentWeatherdate.nodeValue
                currentWeatherday = currentWeather.getAttributeNode('day')
                config.plugins.MetrixWeather.forecastTomorrowday2.value = currentWeatherday.nodeValue
                currentWeathershortday = currentWeather.getAttributeNode(
                    'shortday')
                config.plugins.MetrixWeather.forecastTomorrowshortday2.value = currentWeathershortday.nodeValue

                currentWeather = dom.getElementsByTagName('forecast')[n + 3]
                currentWeatherCode = currentWeather.getAttributeNode(
                    'skycodeday')
                config.plugins.MetrixWeather.forecastTomorrowCode3.value = self.ConvertConditionMSN(
                    currentWeatherCode.nodeValue)
                currentWeatherTemp = currentWeather.getAttributeNode('high')
                config.plugins.MetrixWeather.forecastTomorrowTempMax3.value = currentWeatherTemp.nodeValue
                currentWeatherTemp = currentWeather.getAttributeNode('low')
                config.plugins.MetrixWeather.forecastTomorrowTempMin3.value = currentWeatherTemp.nodeValue
                currentWeatherText = currentWeather.getAttributeNode(
                    'skytextday')
                config.plugins.MetrixWeather.forecastTomorrowText3.value = currentWeatherText.nodeValue
                currentWeatherdate = currentWeather.getAttributeNode('date')
                config.plugins.MetrixWeather.forecastTomorrowdate3.value = currentWeatherdate.nodeValue
                currentWeatherday = currentWeather.getAttributeNode('day')
                config.plugins.MetrixWeather.forecastTomorrowday3.value = currentWeatherday.nodeValue
                currentWeathershortday = currentWeather.getAttributeNode(
                    'shortday')
                config.plugins.MetrixWeather.forecastTomorrowshortday3.value = currentWeathershortday.nodeValue
                if self.check:
                    text = "%s|%s|%s°|%s°|%s°" % (id, name, temp, temp_max,
                                                     temp_min)
                    self.writeCheckFile(text)
                    return
            except IndexError, err:
                self.errorCallback(message=str(err))
                return
            self.setWeatherDataValid(3)
Exemplo n.º 49
0
class get_stream_link:
    def __init__(self):
        #self._callback = None
        self.net = Net()

    def get_stream(self, link):
        hoster = self.get_hostername(link)
        if hoster == 'putlocker':
            return self.streamPutlockerSockshare(link, 'putlocker')
        elif hoster == 'sockshare':
            return self.streamPutlockerSockshare(link, 'sockshare')
        elif hoster == 'youtube':
            return self.youtube(link)
        elif hoster == 'videoslasher':
            return self.videoslaher(link)
        elif hoster == 'faststream':
            return self.generic1(link, 'Faststream', 10)
        elif hoster == 'flashx':
            return self.flashx(link)
        elif hoster == 'vk':
            return self.vk(link)
        elif hoster == 'streamcloud':
            return self.streamcloud(link)
        elif hoster == 'vidstream':
            return self.vidstream(link)
        elif hoster == 'xvidstage':
            return self.xvidstage(link)
        elif hoster == 'videoweed':
            return self.videoweed(link)
        elif hoster == 'nowvideo':
            return self.generic2(link)
        elif hoster == 'movshare':
            return self.generic2(link)
        elif hoster == 'divxstage':
            return self.generic2(link)
        elif hoster == 'novamov':
            return self.generic2(link)
        elif hoster == 'primeshare':
            return self.primeshare(link)
        elif hoster == 'videomega':
            return self.videomega(link)
        elif hoster == 'bitshare':
            return self.bitshare(link)
        elif hoster == 'movreel':
            return self.movreel(link)
        elif hoster == 'uploadc':
            return self.uploadc(link)
        elif hoster == 'youwatch':
            return self.youwatch(link)
        elif hoster == 'yandex':
            return self.generic1(link, 'Yandex', 0)
        elif hoster == 'vidx':
            return self.generic1(link, 'ViDX', 10)
        elif hoster == 'K1no HD':
            return link
        return 'Not Supported'

    def getUrl(self, url):
        req = urllib2.Request(url)
        req.add_header(
            'User-Agent',
            'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
        )
        response = urllib2.urlopen(req)
        data = response.read()
        response.close()
        return data

    def get_adfly_link(self, adflink):
        print 'resolving adfly url: \'%s\' using http://dead.comuv.com/bypasser/process.php' % (
            adflink)
        data = self.net.http_POST('http://dead.comuv.com/bypasser/process.php',
                                  {
                                      'url': adflink
                                  }, {
                                      'Referer': 'http://dead.comuv.com/',
                                      'X-Requested-With': 'XMLHttpRequest'
                                  }).content
        link = re.findall('<a[^>]*href="([^"]*)"', data,
                          re.S | re.I | re.DOTALL)
        if link: return link[0]
        else: return 'empty'

    def get_adfly_link_2(self, adflink):
        print 'resolving adfly url: \'%s\' using http://cyberflux.info/shortlink.php' % (
            adflink)
        data = self.net.http_POST(
            'http://cyberflux.info/shortlink.php', {
                'urllist': adflink
            }, {
                'Referer': 'http://cyberflux.info/shortlink.php'
            }).content
        link = re.findall(adflink + '[ ]*=[ ]*<a[^>]*href=([^>]*)>', data,
                          re.S | re.I | re.DOTALL)
        if link: return link[0]
        else: return 'empty'

    def waitmsg(self, sec, msg):
        dialog = xbmcgui.DialogProgress()
        dialog.create('Resolving', '%s Link.. Wait %s sec.' % (msg, sec))
        dialog.update(0)

        c = 100 / int(sec)
        i = 1
        p = 0

        while i < int(sec) + 1:
            p += int(c)
            time.sleep(1)
            dialog.update(int(p))
            i += 1
        dialog.close()

    def get_hostername(self, link):
        if link:
            for (hoster, urlrex) in hosterlist:
                if re.match(urlrex, link, re.S | re.I): return hoster
        return 'Not Supported'

    def get_stream_url(self, sUnpacked):
        if not sUnpacked: return
        stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked,
                                re.S | re.I | re.DOTALL)
        if not stream_url:
            stream_url = re.findall("file','(.*?)'", sUnpacked,
                                    re.S | re.I | re.DOTALL)
        if not stream_url:
            stream_url = re.findall('file:"(.*?)"', sUnpacked,
                                    re.S | re.I | re.DOTALL)
        if stream_url: return stream_url[0]

    def youtube(self, url, videoPrio=2):
        # this part is from mtube plugin
        print "got url: " + str(url)
        if videoPrio == 0:
            VIDEO_FMT_PRIORITY_MAP = {
                '38': 6,  #MP4 Original (HD)
                '37': 5,  #MP4 1080p (HD)
                '22': 4,  #MP4 720p (HD)
                '35': 2,  #FLV 480p
                '18': 1,  #MP4 360p
                '34': 3,  #FLV 360p
            }
        elif videoPrio == 1:
            VIDEO_FMT_PRIORITY_MAP = {
                '38': 6,  #MP4 Original (HD)
                '37': 5,  #MP4 1080p (HD)
                '22': 1,  #MP4 720p (HD)
                '35': 3,  #FLV 480p
                '18': 2,  #MP4 360p
                '34': 4,  #FLV 360p
            }
        else:
            VIDEO_FMT_PRIORITY_MAP = {
                '38': 3,  #MP4 Original (HD)
                '37': 1,  #MP4 1080p (HD)
                '22': 2,  #MP4 720p (HD)
                '35': 5,  #FLV 480p
                '18': 4,  #MP4 360p
                '34': 6,  #FLV 360p
            }
        video_url = None
        url = url.replace('/embed/', '/watch?v=')
        id = re.findall('watch.v=(.*\D)', url, re.S)
        video_id = id[0]
        # Getting video webpage
        #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
        watch_url = 'http://www.youtube.com/watch?v=%s&gl=DE&hl=de' % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            print "[youtubeUrl] trying to find out if a HD Stream is available", watch_url
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket.error), err:
            return "Error: Unable to retrieve watchpage - Error code: %s" % str(
                err)
            # Get video info
        for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
            info_url = (
                'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=DE&hl=de'
                % (video_id, el))
            request = Request(info_url, None, std_headers)
            try:
                infopage = urlopen2(request).read()
                videoinfo = parse_qs(infopage)
                if ('url_encoded_fmt_stream_map'
                        or 'fmt_url_map') in videoinfo:
                    break
            except (URLError, HTTPException, socket.error), err:
                return "Error: unable to download video infopage - %s" % str(
                    err)
Exemplo n.º 50
0
    def getVideoUrl(self):
        VIDEO_FMT_PRIORITY_MAP = {
            '38': 1,  #MP4 Original (HD)
            '37': 2,  #MP4 1080p (HD)
            '22': 3,  #MP4 720p (HD)
            '18': 4,  #MP4 360p
            '35': 5,  #FLV 480p
            '34': 6,  #FLV 360p
        }
        video_url = None
        video_id = str(self.getTubeId())

        links = {}
        watch_url = 'http://www.youtube.com/watch?v=%s&safeSearch=none' % video_id
        watchrequest = Request(watch_url, None, std_headers)

        try:
            print("[MyTube] trying to find out if a HD Stream is available",
                  watch_url)
            result = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket.error) as err:
            print(
                "[MyTube] Error: Unable to retrieve watchpage - Error code: ",
                str(err))
            return video_url

        # Get video info
        for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
            info_url = (
                'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
                % (video_id, el))
            request = Request(info_url, None, std_headers)
            try:
                infopage = urlopen2(request).read()
                videoinfo = parse_qs(infopage)
                if ('url_encoded_fmt_stream_map'
                        or 'fmt_url_map') in videoinfo:
                    break
            except (URLError, HTTPException, socket.error) as err:
                print("[MyTube] Error: unable to download video infopage",
                      str(err))
                return video_url

        if ('url_encoded_fmt_stream_map' or 'fmt_url_map') not in videoinfo:
            # Attempt to see if YouTube has issued an error message
            if 'reason' not in videoinfo:
                print(
                    '[MyTube] Error: unable to extract "fmt_url_map" or "url_encoded_fmt_stream_map" parameter for unknown reason'
                )
            else:
                reason = unquote_plus(videoinfo['reason'][0])
                print('[MyTube] Error: YouTube said: %s' %
                      reason.decode('utf-8'))
            return video_url

        video_fmt_map = {}
        fmt_infomap = {}
        if videoinfo.has_key('url_encoded_fmt_stream_map'):
            tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split(
                ',')
        else:
            tmp_fmtUrlDATA = videoinfo['fmt_url_map'][0].split(',')
        for fmtstring in tmp_fmtUrlDATA:
            fmturl = fmtid = ""
            if videoinfo.has_key('url_encoded_fmt_stream_map'):
                try:
                    for arg in fmtstring.split('&'):
                        if arg.find('=') >= 0:
                            key, value = arg.split('=')
                            if key == 'itag':
                                if len(value) > 3:
                                    value = value[:2]
                                fmtid = value
                            elif key == 'url':
                                fmturl = value

                    if fmtid != "" and fmturl != "" and VIDEO_FMT_PRIORITY_MAP.has_key(
                            fmtid):
                        video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = {
                            'fmtid': fmtid,
                            'fmturl': unquote_plus(fmturl)
                        }
                        fmt_infomap[int(fmtid)] = "%s" % (unquote_plus(fmturl))
                    fmturl = fmtid = ""

                except:
                    print("error parsing fmtstring:", fmtstring)

            else:
                (fmtid, fmturl) = fmtstring.split('|')
            if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "":
                video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = {
                    'fmtid': fmtid,
                    'fmturl': unquote_plus(fmturl)
                }
                fmt_infomap[int(fmtid)] = unquote_plus(fmturl)
        print("[MyTube] got", sorted(fmt_infomap.iterkeys()))
        if video_fmt_map and len(video_fmt_map):
            print("[MyTube] found best available video format:",
                  video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid'])
            best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]
            video_url = "%s" % (best_video['fmturl'].split(';')[0])
            print("[MyTube] found best available video url:", video_url)

        return video_url
Exemplo n.º 51
0
class MyTubeFeedEntry():
    def __init__(self, feed, entry, favoritesFeed=False):
        self.feed = feed
        self.entry = entry
        self.favoritesFeed = favoritesFeed
        self.thumbnail = {}
        """self.myopener = MyOpener()
		urllib.urlopen = MyOpener().open
		if config.plugins.mytube.general.useHTTPProxy.value is True:
			proxy = {'http': 'http://'+str(config.plugins.mytube.general.ProxyIP.getText())+':'+str(config.plugins.mytube.general.ProxyPort.value)}
			self.myopener = MyOpener(proxies=proxy)
			urllib.urlopen = MyOpener(proxies=proxy).open
		else:
			self.myopener = MyOpener()
			urllib.urlopen = MyOpener().open"""

    def isPlaylistEntry(self):
        return False

    def getTubeId(self):
        #print "[MyTubeFeedEntry] getTubeId"
        ret = None
        if self.entry.media.player:
            split = self.entry.media.player.url.split("=")
            ret = split.pop()
            if ret.startswith('youtube_gdata'):
                tmpval = split.pop()
                if tmpval.endswith("&feature"):
                    tmp = tmpval.split("&")
                    ret = tmp.pop(0)
        return ret

    def getTitle(self):
        #print "[MyTubeFeedEntry] getTitle",self.entry.media.title.text
        return self.entry.media.title.text

    def getDescription(self):
        #print "[MyTubeFeedEntry] getDescription"
        if self.entry.media is not None and self.entry.media.description is not None:
            return self.entry.media.description.text
        return "not vailable"

    def getThumbnailUrl(self, index=0):
        #print "[MyTubeFeedEntry] getThumbnailUrl"
        if index < len(self.entry.media.thumbnail):
            return self.entry.media.thumbnail[index].url
        return None

    def getPublishedDate(self):
        if self.entry.published is not None:
            return self.entry.published.text
        return "unknown"

    def getViews(self):
        if self.entry.statistics is not None:
            return self.entry.statistics.view_count
        return "not available"

    def getDuration(self):
        if self.entry.media is not None and self.entry.media.duration is not None:
            return self.entry.media.duration.seconds
        else:
            return 0

    def getRatingAverage(self):
        if self.entry.rating is not None:
            return self.entry.rating.average
        return 0

    def getNumRaters(self):
        if self.entry.rating is not None:
            return self.entry.rating.num_raters
        return ""

    def getAuthor(self):
        authors = []
        for author in self.entry.author:
            authors.append(author.name.text)
        author = ", ".join(authors)
        return author

    def PrintEntryDetails(self):
        EntryDetails = {
            'Title': None,
            'TubeID': None,
            'Published': None,
            'Published': None,
            'Description': None,
            'Category': None,
            'Tags': None,
            'Duration': None,
            'Views': None,
            'Rating': None,
            'Thumbnails': None
        }
        EntryDetails['Title'] = self.entry.media.title.text
        EntryDetails['TubeID'] = self.getTubeId()
        EntryDetails['Description'] = self.getDescription()
        EntryDetails['Category'] = self.entry.media.category[0].text
        EntryDetails['Tags'] = self.entry.media.keywords.text
        EntryDetails['Published'] = self.getPublishedDate()
        EntryDetails['Views'] = self.getViews()
        EntryDetails['Duration'] = self.getDuration()
        EntryDetails['Rating'] = self.getNumRaters()
        EntryDetails['RatingAverage'] = self.getRatingAverage()
        EntryDetails['Author'] = self.getAuthor()
        # show thumbnails
        list = []
        for thumbnail in self.entry.media.thumbnail:
            print 'Thumbnail url: %s' % thumbnail.url
            list.append(str(thumbnail.url))
        EntryDetails['Thumbnails'] = list
        #print EntryDetails
        return EntryDetails

    def getVideoUrl(self):
        VIDEO_FMT_PRIORITY_MAP = {
            '38': 1,  #MP4 Original (HD)
            '37': 2,  #MP4 1080p (HD)
            '22': 3,  #MP4 720p (HD)
            '18': 4,  #MP4 360p
            '35': 5,  #FLV 480p
            '34': 6,  #FLV 360p
        }
        video_url = None
        video_id = str(self.getTubeId())

        # Getting video webpage
        #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
        watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            print "[MyTube] trying to find out if a HD Stream is available", watch_url
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket.error), err:
            print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(
                err)
            return video_url

        # Get video info
        for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
            info_url = (
                'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
                % (video_id, el))
            request = Request(info_url, None, std_headers)
            try:
                infopage = urlopen2(request).read()
                videoinfo = parse_qs(infopage)
                if ('url_encoded_fmt_stream_map'
                        or 'fmt_url_map') in videoinfo:
                    break
            except (URLError, HTTPException, socket.error), err:
                print "[MyTube] Error: unable to download video infopage", str(
                    err)
                return video_url
Exemplo n.º 52
0
    def getVideoUrl(self, entry):
        std_headers = {
            'User-Agent':
            'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
            'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
            'Accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'en-us,en;q=0.5',
        }

        VIDEO_FMT_PRIORITY_MAP = {
            '18': 4,  #MP4 360p
            '35': 5,  #FLV 480p
            '34': 6,  #FLV 360p
        }

        if int(config.plugins.yttrailer.best_resolution.value) <= 1:
            VIDEO_FMT_PRIORITY_MAP["38"] = 1  #MP4 Original (HD)
            VIDEO_FMT_PRIORITY_MAP["22"] = 3  #MP4 720p (HD)

            if int(config.plugins.yttrailer.best_resolution.value) == 0:
                VIDEO_FMT_PRIORITY_MAP["37"] = 2  #MP4 1080p (HD)

        video_url = None
        video_id = str(self.getTubeId(entry))

        # Getting video webpage
        #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
        watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            print("[YTTrailer] trying to find out if a HD Stream is available",
                  watch_url)
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket_error) as err:
            print(
                "[YTTrailer] Error: Unable to retrieve watchpage - Error code: ",
                str(err))
            return video_url

        # Get video info
        for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
            info_url = (
                'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
                % (video_id, el))
            request = Request(info_url, None, std_headers)
            try:
                infopage = urlopen2(request).read()
                videoinfo = parse_qs(infopage)
                if ('url_encoded_fmt_stream_map'
                        or 'fmt_url_map') in videoinfo:
                    break
            except (URLError, HTTPException, socket_error) as err:
                print("[YTTrailer] Error: unable to download video infopage",
                      str(err))
                return video_url

        if ('url_encoded_fmt_stream_map' or 'fmt_url_map') not in videoinfo:
            # Attempt to see if YouTube has issued an error message
            if 'reason' not in videoinfo:
                print(
                    '[YTTrailer] Error: unable to extract "url_encoded_fmt_stream_map" or "fmt_url_map" parameter for unknown reason'
                )
            else:
                reason = unquote_plus(videoinfo['reason'][0])
                print('[YTTrailer] Error: YouTube said: %s' %
                      reason.decode('utf-8'))
            return video_url

        video_fmt_map = {}
        fmt_infomap = {}

        if videoinfo.has_key('url_encoded_fmt_stream_map'):
            tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split(
                ',')
        else:
            tmp_fmtUrlDATA = videoinfo['fmt_url_map'][0].split(',')
        for fmtstring in tmp_fmtUrlDATA:
            fmturl = fmtid = ""
            if videoinfo.has_key('url_encoded_fmt_stream_map'):
                try:
                    for arg in fmtstring.split('&'):
                        if arg.find('=') >= 0:
                            print(arg.split('='))
                            key, value = arg.split('=')
                            if key == 'itag':
                                if len(value) > 3:
                                    value = value[:2]
                                fmtid = value
                            elif key == 'url':
                                fmturl = value

                    if fmtid != "" and fmturl != "" and VIDEO_FMT_PRIORITY_MAP.has_key(
                            fmtid):
                        video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = {
                            'fmtid': fmtid,
                            'fmturl': unquote_plus(fmturl)
                        }
                        fmt_infomap[int(fmtid)] = "%s" % (unquote_plus(fmturl))
                    fmturl = fmtid = ""

                except:
                    print("error parsing fmtstring:", fmtstring)

            else:
                (fmtid, fmturl) = fmtstring.split('|')
            if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "":
                video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = {
                    'fmtid': fmtid,
                    'fmturl': unquote_plus(fmturl)
                }
                fmt_infomap[int(fmtid)] = unquote_plus(fmturl)
        print("[YTTrailer] got", sorted(fmt_infomap.iterkeys()))
        if video_fmt_map and len(video_fmt_map):
            print("[YTTrailer] found best available video format:",
                  video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid'])
            best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]
            video_url = "%s" % (best_video['fmturl'].split(';')[0])
            print("[YTTrailer] found best available video url:", video_url)

        return video_url