Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging with date_format #65

Open
jstagge opened this issue Nov 2, 2016 · 4 comments
Open

Tagging with date_format #65

jstagge opened this issue Nov 2, 2016 · 4 comments

Comments

@jstagge
Copy link

jstagge commented Nov 2, 2016

I am attempting to download a file using a custom name of the format: YYYYMMDD-filename.mp3

Here are the relevant settings:

date_format = %Y%m%d
file_to_tag = {date}-{filename_title}.mp3
downloadhandler = wget {link} -O {directory}/{date}-{filename_title}.mp3

When I run this, I receive the following error:

Traceback (most recent call last):
File "/usr/bin/greg", line 11, in
load_entry_point('Greg==0.4.7', 'console_scripts', 'greg')()
File "/usr/lib/python3.5/site-packages/greg/parser.py", line 138, in main
function(vars(args))
File "/usr/lib/python3.5/site-packages/greg/commands.py", line 176, in sync
downloaded = feed.download_entry(entry)
File "/usr/lib/python3.5/site-packages/greg/classes.py", line 325, in download_entry
placeholders = aux.check_directory(placeholders)
File "/usr/lib/python3.5/site-packages/greg/aux_functions.py", line 142, in check_directory
subdnametemplate, placeholders)
File "/usr/lib/python3.5/site-packages/greg/aux_functions.py", line 284, in substitute_placeholders
date=placeholders.date_string(),
File "/usr/lib/python3.5/site-packages/greg/classes.py", line 373, in date_string
date_format = self.feed.retrieve_config("date_format", "%Y-%m-%d")
File "/usr/lib/python3.5/site-packages/greg/classes.py", line 135, in retrieve_config
answer = self.config.get(section, value, fallback=default)
File "/usr/lib/python3.5/configparser.py", line 797, in get
d)
File "/usr/lib/python3.5/configparser.py", line 393, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
File "/usr/lib/python3.5/configparser.py", line 443, in _interpolate_some
"found: %r" % (rest,))
configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%Y%m%d'

@manolomartinez
Copy link
Owner

Hi, thanks for your report. You were right and I was wrong. It should be

date_format = %%Y%%m%%d

to avoid interpolation errors, of course. Changing this in the config file, this seems to work in my tests. What is the problem you are seeing?

Manolo

@jstagge
Copy link
Author

jstagge commented Nov 2, 2016

You are correct, this does work. My problem was the config setting:
tag_date = {date}
which throws the following error:
/usr/lib/python3.5/site-packages/stagger/tags.py:711: FrameWarning: TSOA: Ignoring incompatible frame
FrameWarning)
/usr/lib/python3.5/site-packages/stagger/tags.py:711: FrameWarning: TSOP: Ignoring incompatible frame
FrameWarning)
Traceback (most recent call last):
File "/usr/bin/greg", line 11, in
load_entry_point('Greg==0.4.7', 'console_scripts', 'greg')()
File "/usr/lib/python3.5/site-packages/greg/parser.py", line 138, in main
function(vars(args))
File "/usr/lib/python3.5/site-packages/greg/commands.py", line 176, in sync
downloaded = feed.download_entry(entry)
File "/usr/lib/python3.5/site-packages/greg/classes.py", line 331, in download_entry
aux.tag(placeholders)
File "/usr/lib/python3.5/site-packages/greg/aux_functions.py", line 198, in tag
stagger.util.set_frames(podpath, {tag: metadata})
File "/usr/lib/python3.5/site-packages/stagger/util.py", line 103, in set_frames
setattr(tag, key, value)
File "/usr/lib/python3.5/site-packages/stagger/tags.py", line 863, in date
self._validate_friendly_date(value)
File "/usr/lib/python3.5/site-packages/stagger/tags.py", line 450, in _validate_friendly_date
raise ValueError("date must be in 'YYYY-MM-DD HH:MM:SS' format")
ValueError: date must be in 'YYYY-MM-DD HH:MM:SS' format

So, this is a very minor issue caused by trying to tag with a modified date/time.

@manolomartinez
Copy link
Owner

Right, so the issue here is that, once you modify the date format, stagger complains, isn't it?
I can see how this is a nuisance.

One possible solution is to have a {date_stagger} placeholder that keeps the date in the format expected by stagger. It looks a bit clunky, perhaps. Other options?

@jstagge
Copy link
Author

jstagge commented Nov 3, 2016

For my purposes, I am happy to not include the
tag_date = {date}

I think your solution makes the most sense. This is far from a critical item, but maybe could be introduced in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants