Hellp needed to pick file modification time as originally_available_at

Hello,

I’m trying to write a simple agent that will use the file modification date as a metadata for the originally release date.

It work well for home video, but it does not work for home serie.

Here it’s what I did for home video. I build a new agent from the LocalMedia.bundle Agent and I add those lines in the “class localMediaMovie(Agent.Movies)” (renamed for something else in my agent):

    # Get the filename and the mod time.
    filename = unicodize(media.items[0].parts[0].file)
    mod_time = os.path.getmtime(filename)
    date = datetime.date.fromtimestamp(mod_time)

    metadata.year = date.year
    metadata.originally_available_at = Datetime.ParseDate(str(date)).date()

It work perfectly, and I can put that agent on top in the Agent list.

Here it’s my best try for home serie (inspired from “class localMediaTV(Agent.TV_Shows)”):

	# Borrow from the "Look for subtitles for each episode".
	for s in media.seasons:
        for e in media.seasons[s].episodes:
          for i in media.seasons[s].episodes[e].items:
            for part in i.parts:
              localmedia.findSubtitles(part)
	          # Get the filename and the mod time.
              filename = unicodize(media.seasons[s].episodes[e].items[i].parts[part].file)
			  mod_time = os.path.getmtime(filename)
			  date = datetime.date.fromtimestamp(mod_time)

			  episodeMetadata.year = date.year
			  episodeMetadata.originally_available_at = Datetime.ParseDate(str(date)).date()

What’s wrong? The agent does not show up in the Agent list.

Thanks for your help,

Claude Fortier

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.