Beispiel #1
0
def main():
    argparser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        description='Simple YouTube Downloader')
    argparser.add_argument('keywords', help='동영상 url', nargs='*')
    args = argparser.parse_args()

    for url in args.keywords:
        regx_direct_link = re.compile(r'^https://youtu.be/(?P<content_id>.+)$')
        m = regx_direct_link.search(url)
        if m:
            get_youtube_content(url)
        else:
            keywords = ' '.join(args.keywords)
            results = get_search_results(keywords)
            for i, row in enumerate(results, 1):
                line = f"{i}. {row['title']}"
                print(line)

            print(
                '============================================================================='
            )
            nlist = input('Input Your choices as seperate with comma: ')
            if not nlist:
                break
            nlist = nlist.split(',')
            nlist = list(map(int, nlist))
            for i, row in enumerate(results, 1):
                if i in nlist:
                    get_youtube_content(row['link'])
Beispiel #2
0
def search_ep(guid):
    '''
    Schema:
    {
        'search_query': text (str),
        'leg_datetime_range': [from_date (str), to_date (str)],
        'kive_datetime_range': [from_date (str), to_date (str)],
        'la_datetime_range': [from_date (str), to_date (str)],
        'media_query': [list of media filenames/extensions (str), ...],
        'options': [selected options]
    }
    '''

    response = None
    try:
        json = request.get_json()
        response = get_search_results(
            search_text=json['search_query'],
            leg_datetime_range=json['date_ingested_legacy'],
            kive_datetime_range=json['date_ingested_kive'],
            la_datetime_range=json['date_last_accessed'],
            media_text_lst=json['media_query'],
            fields_lst=json['options'],
            workspace_guid=guid)

    except Exception as e:
        response = {
            'message': "search-failure",
            'error': str(traceback.format_exc())
        }  #str(e)}
    return jsonify(response)
Beispiel #3
0
def api_search():
    """
    Searches for things of a given category that match a partial string.
    Returns a dictionary mapping IDs to names.

    Args:
        category (str)
            A category name such as `character`, `corporation`, `system`,
            `alliance`, 'inventory_type`, or `region`.
        search (str)
            A partial search string

    Returns:
        response (dict)
            Entries are mappings from ids to names.

    Example:
        response = {
            'info': [
                '1937622137': 'Twine Endashi',
                ...
            ]
        }

    Error codes:
        Forbidden (403): If logged in user is not a recruiter or admin
        Bad request (400): If category is not a valid category
    """
    category = request.args.get('category')
    search = request.args.get('search')
    return jsonify(
        get_search_results(category, search, current_user=current_user))
 def test_search_no_result(self):
     response = get_search_results('character',
                                   'reafldksjcjluresfda',
                                   current_user=self.admin)
     self.assertIn('info', response)
     data = response['info']
     self.assertEqual(len(data), 0)
 def test_search_for_ascendance(self):
     response = get_search_results('corporation',
                                   'Ascendance',
                                   current_user=self.admin)
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(98409330, data)
     self.assertEqual(data[98409330], 'Ascendance')
 def test_search_for_jita(self):
     response = get_search_results('system',
                                   'Jita',
                                   current_user=self.admin)
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(30000142, data)
     self.assertEqual(data[30000142], 'Jita')
 def test_search_for_querious(self):
     response = get_search_results('region',
                                   'Querious',
                                   current_user=self.admin)
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(10000050, data)
     self.assertEqual(data[10000050], 'Querious')
 def test_search_for_applicant_partial_match(self):
     response = get_search_results('character',
                                   self.applicant.name[:5],
                                   current_user=self.admin)
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(self.applicant.id, data)
     self.assertEqual(data[self.applicant.id], self.applicant.name)
Beispiel #9
0
def handle_search(request):
	if request.method == 'OPTIONS':
		return utils.CORS_response()
	if request.method == 'GET':
		return search.get_search_results(request)
	elif request.method == 'POST':
		return search.make_housing_post(request)
	elif request.method == 'DELETE':
		return search.clear_all_housing_data(request)
	return HttpResponseNotAllowed(['GET', 'POST', 'DELETE', 'OPTIONS'])
Beispiel #10
0
def search_helper(cmd_list) -> str:
    if (len(cmd_list) < 1):
        return INVALID_FORMAT + ", you must enter a value after 'search'"

    # if the query contains spaces, convert the spaces to -'s
    if (len(cmd_list) > 1):
        query = ""
        for i in range(len(cmd_list)):
            query += cmd_list[i]
            if (i != len(cmd_list) - 1):
                query += "-"

    # contained no spaces
    else:
        query = cmd_list[0]

    return get_search_results(query)
Beispiel #11
0
def get_summary():
    #  source_text = request.form["sourceText"]
    source_text = request.get_json(force=True)["sourceText"]
    #  summary = f"This is a fake {mode} summary with {decoder}.\nThe long document:{source_text}"
    # summary = __get_summary(mode, decoder, source_text)
    with Pool(2) as pool:
        pool_output = pool.starmap(__get_summary,
                                   [("abs", "trans", source_text),
                                    ("ext", "trans", source_text)])
    abs_summary, ext_summary = pool_output[:2]
    search_results = get_search_results(abs_summary)
    summary = json.dumps(
        {
            "abs": abs_summary,
            "ext": ext_summary[0],
            "highlighted": ext_summary[1],
            "searchResults": search_results
        },
        ensure_ascii=False)
    print(summary)
    resp = make_response(summary)
    resp.status_code = 200
    resp.headers['Access-Control-Allow-Origin'] = '*'
    return resp
 def test_search_invalid_category(self):
     with self.assertRaises(BadRequestException):
         get_search_results('type', 'Hel', current_user=self.admin)
 def test_search_no_not_applicant_access(self):
     with self.assertRaises(ForbiddenException):
         get_search_results('character',
                            self.applicant.name,
                            current_user=self.not_applicant)
def search(query):
    return get_search_results(query)