def update_dailymotion()

in gnm_deliverables/launch_detector.py [0:0]


def update_dailymotion(msg: LaunchDetectorUpdate, asset: DeliverableAsset):
    """
    either create or update a dailymotion information object from the given message
    :param msg: LaunchDetectorUpdate instance giving the content to update
    :param asset: DeliverableAsset that needs to be updated.
    :return:
    """
    if asset.DailyMotion_master is None:
        rec: DailyMotion = DailyMotion()
    else:
        rec: DailyMotion = asset.DailyMotion_master

    #would be good to build a mapping table for this
    #rec.daily_motion_category
    if rec.daily_motion_description is None or rec.daily_motion_description == "":
        rec.daily_motion_description = msg.description
    if rec.daily_motion_tags is None or len(rec.daily_motion_tags) == 0:
        #would be good to map these to names
        rec.daily_motion_tags = msg.keywords
    if rec.daily_motion_title is None or rec.daily_motion_title=="":
        rec.daily_motion_title = msg.title
    if rec.daily_motion_no_mobile_access is None:
        rec.daily_motion_no_mobile_access = False
    if rec.daily_motion_contains_adult_content is None:
        rec.daily_motion_contains_adult_content = False

    # set the etag in case something else is editing it at the moment
    rec.etag = zoned_datetime().isoformat('T')

    asset.DailyMotion_master = rec  #no-op if it was already set like this
    rec.save()
    asset.save()