gperdrizet commited on
Commit
687d26a
·
unverified ·
1 Parent(s): 8698e3d

Renamed feed retreival and parsing tool.

Browse files
functions/{helper_functions.py → feed_extraction.py} RENAMED
File without changes
functions/tools.py CHANGED
@@ -2,30 +2,33 @@
2
 
3
  import json
4
  import logging
5
- import functions.helper_functions as helper_funcs
6
 
7
 
8
- def get_content(website: str) -> list:
9
- '''Gets RSS feed content from a given website.
 
 
 
10
 
11
  Args:
12
- website_url: URL or nam of website to extract RSS feed content from
13
 
14
  Returns:
15
- List of titles for the 10 most recent entries in the RSS feed from the
16
- requested website.
17
  '''
18
 
19
  logger = logging.getLogger(__name__ + '.get_content')
20
  logger.info('Getting feed content for: %s', website)
21
 
22
- feed_uri = helper_funcs.find_feed_uri(website)
23
  logger.info('find_feed_uri() returned %s', feed_uri)
24
 
25
  if 'No feed found' in feed_uri:
26
  return 'No feed found'
27
 
28
- content = helper_funcs.parse_feed(feed_uri)
29
  logger.info('parse_feed() returned %s entries', len(list(content.keys())))
30
 
31
  return json.dumps(content)
 
2
 
3
  import json
4
  import logging
5
+ import functions.feed_extraction as extraction_funcs
6
 
7
 
8
+ def get_feed(website: str) -> list:
9
+ '''Gets RSS feed content from a given website. Can take a website or RSS
10
+ feed URL directly, or the name of a website. Will attempt to find RSS
11
+ feed and return title, summary and link to full article for most recent
12
+ items in feed
13
 
14
  Args:
15
+ website: URL or name of website to extract RSS feed content from
16
 
17
  Returns:
18
+ JSON string containing the feed content or 'No feed found' if a RSS
19
+ feed for the requested website could not be found
20
  '''
21
 
22
  logger = logging.getLogger(__name__ + '.get_content')
23
  logger.info('Getting feed content for: %s', website)
24
 
25
+ feed_uri = extraction_funcs.find_feed_uri(website)
26
  logger.info('find_feed_uri() returned %s', feed_uri)
27
 
28
  if 'No feed found' in feed_uri:
29
  return 'No feed found'
30
 
31
+ content = extraction_funcs.parse_feed(feed_uri)
32
  logger.info('parse_feed() returned %s entries', len(list(content.keys())))
33
 
34
  return json.dumps(content)
rss_server.py CHANGED
@@ -39,7 +39,7 @@ with gr.Blocks() as demo:
39
  submit_button = gr.Button('Submit')
40
 
41
  submit_button.click( # pylint: disable=no-member
42
- fn=tool_funcs.get_content,
43
  inputs=website_url,
44
  outputs=output,
45
  api_name='Get RSS feed content'
 
39
  submit_button = gr.Button('Submit')
40
 
41
  submit_button.click( # pylint: disable=no-member
42
+ fn=tool_funcs.get_feed,
43
  inputs=website_url,
44
  outputs=output,
45
  api_name='Get RSS feed content'