def remove_feed(chat_id, feed_url):
'''Function to remove (unsubscribe) a feed from the chat feeds file'''
# Create TSjson object for feeds of chat file and read the content
fjson_chat_feeds = TSjson.TSjson('{}/{}.json'.format(CONST['CHATS_DIR'], chat_id))
subs_feeds = fjson_chat_feeds.read_content()
subs_feeds = subs_feeds[0]
# Get the feed and set json data
feed = {}
feedpars = parse(feed_url)
feed['Title'] = feedpars['feed']['title']
feed['URL'] = feed_url
feed['SEARCH_TERMS'] = []
for sub_feed in subs_feeds['Feeds']:
if sub_feed['URL'] == feed['URL']:
feed['SEARCH_TERMS'] = sub_feed['SEARCH_TERMS']
break
# Remove the specific feed and update json file
subs_feeds['Feeds'].remove(feed)
fjson_chat_feeds.update(subs_feeds, 'Chat_id')
评论列表
文章目录