Skip to content

Commit

Permalink
Merge pull request #931 from marwoodandrew/bang-time
Browse files Browse the repository at this point in the history
Bang parser, assume timezone is London not UTC
  • Loading branch information
marwoodandrew authored May 28, 2024
2 parents fa9c1df + eddbb5d commit 30ce241
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/aap/io/feed_parsers/bang_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from superdesk.utc import utc
import pytz
from superdesk.io.feed_parsers.newsml_1_2 import NewsMLOneFeedParser
from superdesk.io.registry import register_feed_parser
from superdesk.errors import ParserError
Expand All @@ -24,7 +24,11 @@ class BangShowbizParser(NewsMLOneFeedParser):
subject_map = {MUSIC_ID: "01011000", MOVIES_ID: "01005001", SHOWBIZ_ID: "01021000"}

def datetime(self, string):
return datetime.strptime(string, "%Y-%m-%d %H:%M:%S").replace(tzinfo=utc)
# Assume that timezone of the input datetime is London
local_dt = datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
local_tz = pytz.timezone("Europe/London")
utc_dt = local_tz.localize(local_dt, is_dst=None).astimezone(pytz.utc)
return utc_dt

def parse(self, xml, provider=None):
self.provider = provider
Expand Down Expand Up @@ -89,6 +93,7 @@ def parse_news_identifier(self, item, tree):
def parse_news_management(self, item, tree):
# It's always entertainment
item["anpa_category"] = [{"qcode": "e"}]
item["original_source"] = "BANG"


register_feed_parser(BangShowbizParser.NAME, BangShowbizParser())

0 comments on commit 30ce241

Please sign in to comment.