@@ -2373,7 +2373,7 @@ def _get_cached_feed(output,
23732373 inputs ,
23742374 item_type ,
23752375 feed_type = feed_type ,
2376- _refresh = refresh ,
2376+ refresh = refresh ,
23772377 feed_history = feed_history ,
23782378 ttl = feed_history .ONE_HOUR ):
23792379 feeds = output ['feeds' ]
@@ -2392,10 +2392,11 @@ def _get_cached_feed(output,
23922392 item_id = item_id .replace ('UC' , channel_prefix , 1 )
23932393 else :
23942394 channel_id = None
2395- cached = feed_history .get_item (item_id , seconds = ttl )
23962395
2396+ cached = feed_history .get_item (item_id )
23972397 if cached :
23982398 feed_details = cached ['value' ]
2399+ _refresh = refresh or cached ['age' ] > ttl
23992400 feed_details ['refresh' ] = _refresh
24002401 if channel_id :
24012402 feed_details .setdefault ('channel_id' , channel_id )
@@ -2445,10 +2446,11 @@ def _get_feed(output,
24452446 if response is None :
24462447 return False , True
24472448 with response :
2448- if response .status_code == 404 :
2449- content = None
2450- elif response .status_code == 429 :
2449+ status_code = response .status_code
2450+ if status_code == 429 :
24512451 return False , True
2452+ if status_code == 404 :
2453+ content = None
24522454 elif stream :
24532455 parser = ET_XMLParser (encoding = 'utf-8' )
24542456 for chunk in response .iter_content (chunk_size = (8 * 1024 )):
@@ -2462,9 +2464,8 @@ def _get_feed(output,
24622464 _output = {
24632465 'channel_id' : channel_id ,
24642466 'content' : content ,
2465- 'refresh' : True ,
2467+ 'refresh' : content is not None ,
24662468 }
2467-
24682469 feeds = output ['feeds' ]
24692470 if item_id in feeds :
24702471 feeds [item_id ].update (_output )
0 commit comments