Exemplo n.º 1
0
    def get(self, search_string):
        ts = request.args.get('ts')
        signature = request.args.get('signature')

        if ts == None or signature == None or ts_signature_validation(
                ts, signature) == False:
            return {'status': 401, 'message': 'Invalid signature'}, 401

        default = "/default.jpg"
        hq = "/hqdefault.jpg"
        mq = "/mqdefault.jpg"
        sd = "/sddefault.jpg"
        max = "/maxresdefault.jpg"
        #
        source_url = "http://gdata.youtube.com/feeds/api/videos?q=" + search_string + "+official+trailer"
        feed = requests.get(source_url)
        data = feedparser.parse(feed.content)
        response = {}
        response['title'] = search_string
        if len(data.entries) > 0:
            try:
                feed = data.entries[0]
                response['trailer'] = feed.link.replace(
                    "&feature=youtube_gdata", "")
                thumb_path = feed.media_thumbnail[0]['url'].rsplit("/", 1)[0]
                response["defaultThumb"] = thumb_path + default
                response["hqThumb"] = thumb_path + hq
                response["mqThumb"] = thumb_path + mq
                response["sdThumb"] = thumb_path + sd
                response["maxThumb"] = thumb_path + max
            except Exception as e:
                logger.error(e)
                pass
        return response, 200
Exemplo n.º 2
0
    def get(self, search_string):
        ts = request.args.get('ts')
        signature = request.args.get('signature')

        if ts == None or signature == None or ts_signature_validation(
                ts, signature) == False:
            return {'status': 401, 'message': 'Invalid signature'}, 401

        default = "/default.jpg"
        hq = "/hqdefault.jpg"
        mq = "/mqdefault.jpg"
        sd = "/sddefault.jpg"
        max = "/maxresdefault.jpg"
        #
        source_url = "http://www.youtube.com/results?search_query=" + search_string + " trailer"
        youtube_page = requests.get(source_url)
        soup = BeautifulSoup(youtube_page.content)
        k = soup.find(id="search-results")
        response = {}
        response["trailer"] = "http://www.youtube.com{0}".format(
            k.a.get('href'))
        thumb_path = "http:{0}".format(k.img['src']).rsplit("/", 1)[0]
        response["defaultThumb"] = thumb_path + default
        response["hqThumb"] = thumb_path + hq
        response["mqThumb"] = thumb_path + mq
        response["sdThumb"] = thumb_path + sd
        response["maxThumb"] = thumb_path + max
        return response
Exemplo n.º 3
0
    def get(self, search_string):
        ts=request.args.get('ts')
        signature=request.args.get('signature')

        if ts ==None or signature==None or ts_signature_validation(ts,signature)==False:
           return {'status':401,'message':'Invalid signature'},401

        default = "/default.jpg"
        hq = "/hqdefault.jpg"
        mq = "/mqdefault.jpg"
        sd = "/sddefault.jpg"
        max = "/maxresdefault.jpg"
        #
        source_url = "http://gdata.youtube.com/feeds/api/videos?q=" + search_string + "+official+trailer"
        feed = requests.get(source_url)
        data=feedparser.parse(feed.content)
        response={}
        response['title']=search_string
        if len(data.entries) > 0:
            try:
                feed=data.entries[0];
                response['trailer']=feed.link.replace("&feature=youtube_gdata","")
                thumb_path = feed.media_thumbnail[0]['url'].rsplit("/", 1)[0]
                response["defaultThumb"] = thumb_path + default
                response["hqThumb"] = thumb_path + hq
                response["mqThumb"] = thumb_path + mq
                response["sdThumb"] = thumb_path + sd
                response["maxThumb"] = thumb_path + max
            except Exception as e:
                logger.error(e)
                pass
        return response,200
Exemplo n.º 4
0
    def get(self, search_string):
        ts=request.args.get('ts')
        signature=request.args.get('signature')

        if ts ==None or signature==None or ts_signature_validation(ts,signature)==False:
            return {'status':401,'message':'Invalid signature'},401

        default = "/default.jpg"
        hq = "/hqdefault.jpg"
        mq = "/mqdefault.jpg"
        sd = "/sddefault.jpg"
        max = "/maxresdefault.jpg"
        #
        source_url = "http://www.youtube.com/results?search_query=" + search_string + " trailer"
        youtube_page = requests.get(source_url)
        soup = BeautifulSoup(youtube_page.content)
        k = soup.find(id="search-results")
        response = {}
        response["trailer"] = "http://www.youtube.com{0}".format(k.a.get('href'))
        thumb_path = "http:{0}".format(k.img['src']).rsplit("/", 1)[0]
        response["defaultThumb"] = thumb_path + default
        response["hqThumb"] = thumb_path + hq
        response["mqThumb"] = thumb_path + mq
        response["sdThumb"] = thumb_path + sd
        response["maxThumb"] = thumb_path + max
        return response
Exemplo n.º 5
0
    def get(self):
        try:
            limit = request.args.get('limit')
            page = request.args.get('page')
            ts = request.args.get('ts')
            signature = request.args.get('signature')

            if ts == None or signature == None or limit == None or page == None:
                return {'status': 400, 'message': 'Bad Request'}, 400

            if ts_signature_validation(ts, signature) == False:
                return {'status': 401, 'message': 'Invalid signature'}, 401

            search_result = rt_upcoming(limit, page)
            response = {}
            response['data'] = {}
            response['data']['count'] = search_result['total']
            response['data']['movies'] = get_detailed_movies(search_result['movies'])
            return response
        except Exception as e:
            logger.exception(e)
            return 'Error in UpComing : ' + str(e), 500
Exemplo n.º 6
0
    def get(self):
        try:
            limit = request.args.get('limit')
            ts = request.args.get('ts')
            signature = request.args.get('signature')

            if ts == None or signature == None or limit == None:
                return {'status': 400, 'message': 'Bad Request'}, 400

            if ts_signature_validation(ts, signature) == False:
                return {'status': 401, 'message': 'Invalid signature'}, 401

            search_result = rt_boxoffice(limit)
            response = {}
            response['data'] = {}
            movies = get_detailed_movies(search_result['movies'])
            response['data']['movies'] = movies
            response['data']['count'] = len(movies)
            return response
        except Exception as e:
            logger.exception(e)
            return 'Error in BoxOffice : ' + str(e), 500
Exemplo n.º 7
0
    def get(self):
        try:
            limit = request.args.get('limit')
            ts = request.args.get('ts')
            signature = request.args.get('signature')

            if ts == None or signature == None or limit == None:
                return {'status': 400, 'message': 'Bad Request'}, 400

            if ts_signature_validation(ts, signature) == False:
                return {'status': 401, 'message': 'Invalid signature'}, 401

            search_result = rt_boxoffice(limit)
            response = {}
            response['data'] = {}
            movies = get_detailed_movies(search_result['movies'])
            response['data']['movies'] = movies
            response['data']['count'] = len(movies)
            return response
        except Exception as e:
            logger.exception(e)
            return 'Error in BoxOffice : ' + str(e), 500
Exemplo n.º 8
0
    def get(self):
        try:
            limit = request.args.get("limit")
            page = request.args.get("page")
            ts = request.args.get("ts")
            signature = request.args.get("signature")

            if ts == None or signature == None or limit == None or page == None:
                return {"status": 400, "message": "Bad Request"}, 400

            if ts_signature_validation(ts, signature) == False:
                return {"status": 401, "message": "Invalid signature"}, 401

            search_result = rt_upcoming(limit, page)
            response = {}
            response["data"] = {}
            response["data"]["count"] = search_result["total"]
            response["data"]["movies"] = get_detailed_movies(search_result["movies"])
            return response
        except Exception as e:
            logger.exception(e)
            return "Error in UpComing : " + str(e), 500
Exemplo n.º 9
0
    def get(self):
        try:
            limit = request.args.get("limit")
            ts = request.args.get("ts")
            signature = request.args.get("signature")

            if ts == None or signature == None or limit == None:
                return {"status": 400, "message": "Bad Request"}, 400

            if ts_signature_validation(ts, signature) == False:
                return {"status": 401, "message": "Invalid signature"}, 401

            search_result = rt_boxoffice(limit)
            response = {}
            response["data"] = {}
            movies = get_detailed_movies(search_result["movies"])
            response["data"]["movies"] = movies
            response["data"]["count"] = len(movies)
            return response
        except Exception as e:
            logger.exception(e)
            return "Error in BoxOffice : " + str(e), 500
Exemplo n.º 10
0
    def get(self, search_string):
        try:
            limit = request.args.get('limit')
            page = request.args.get('page')
            ts = request.args.get('ts')
            signature = request.args.get('signature')

            if ts == None or signature == None or limit == None:
                return {'status': 400, 'message': 'Bad Request'}, 400

            if ts_signature_validation(ts, signature) == False:
                return {'status': 401, 'message': 'Invalid signature'}, 401

            search_result = rt_search(search_string, limit, page)
            response = {}
            response['data'] = {}
            response['data']['count'] = search_result['total']
            response['data']['movies'] = get_detailed_movies(search_result['movies'])
            store_movies('id', search_result['movies'], Config.COLLECTION_RT)
            return response
        except Exception as e:
            logger.exception(e)
            return 'Error in Search : ' + str(e), 500
Exemplo n.º 11
0
    def get(self):
        try:
            limit = request.args.get('limit')
            page = request.args.get('page')
            ts = request.args.get('ts')
            signature = request.args.get('signature')

            if ts == None or signature == None or limit == None or page == None:
                return {'status': 400, 'message': 'Bad Request'}, 400

            if ts_signature_validation(ts, signature) == False:
                return {'status': 401, 'message': 'Invalid signature'}, 401

            search_result = rt_upcoming(limit, page)
            response = {}
            response['data'] = {}
            response['data']['count'] = search_result['total']
            response['data']['movies'] = get_detailed_movies(
                search_result['movies'])
            return response
        except Exception as e:
            logger.exception(e)
            return 'Error in UpComing : ' + str(e), 500
Exemplo n.º 12
0
    def get(self, search_string):
        try:
            limit = request.args.get("limit")
            page = request.args.get("page")
            ts = request.args.get("ts")
            signature = request.args.get("signature")

            if ts == None or signature == None or limit == None:
                return {"status": 400, "message": "Bad Request"}, 400

            if ts_signature_validation(ts, signature) == False:
                return {"status": 401, "message": "Invalid signature"}, 401

            search_result = rt_search(search_string, limit, page)
            response = {}
            response["data"] = {}
            response["data"]["count"] = search_result["total"]
            response["data"]["movies"] = get_detailed_movies(search_result["movies"])
            store_movies("id", search_result["movies"], Config.COLLECTION_RT)
            return response
        except Exception as e:
            logger.exception(e)
            return "Error in Search : " + str(e), 500
Exemplo n.º 13
0
    def get(self, search_string):
        try:
            limit = request.args.get('limit')
            page = request.args.get('page')
            ts = request.args.get('ts')
            signature = request.args.get('signature')

            if ts == None or signature == None or limit == None:
                return {'status': 400, 'message': 'Bad Request'}, 400

            if ts_signature_validation(ts, signature) == False:
                return {'status': 401, 'message': 'Invalid signature'}, 401

            search_result = rt_search(search_string, limit, page)
            response = {}
            response['data'] = {}
            response['data']['count'] = search_result['total']
            response['data']['movies'] = get_detailed_movies(
                search_result['movies'])
            store_movies('id', search_result['movies'], Config.COLLECTION_RT)
            return response
        except Exception as e:
            logger.exception(e)
            return 'Error in Search : ' + str(e), 500