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

Options to rename files #16

Closed
brokkr opened this issue Aug 22, 2016 · 7 comments
Closed

Options to rename files #16

brokkr opened this issue Aug 22, 2016 · 7 comments

Comments

@brokkr
Copy link
Owner

brokkr commented Aug 22, 2016

Many podcasts have either random UID filenames or just name the files inconsistently. This can cause problems with the order in which the files appear in a player.

We should have options for each podcast to rename files based on:

  • Metadata
  • feed data
  • pubDate
  • serial number running from first downloaded to latest
  • ?

Instead of giving free reins we could simply start by having a few simple prepackaged solutions for misbehaving podcasts.

We might also need sign scrubbing similar to derailleur?

@brokkr
Copy link
Owner Author

brokkr commented May 31, 2017

Two solutions here:

  • Variables and regexes
  • Prepackaged, i.e. leave it as is or use 'tracknumber-title'

The first seems like overkill. The second feels arbitrary. It's unlikely to accomodate user preferences so the only thing it would be good for is the possibility that it could help with ordering. However, we do now have the option to use artifical track numbers. Most players will only use file names as a fallback when there are no track numbers.

All things considered I do't think this one is worth it for now.

@brokkr brokkr closed this as completed May 31, 2017
@brokkr brokkr added the wontfix label May 31, 2017
@brokkr brokkr removed this from the 0.9 milestone May 31, 2017
@brokkr brokkr reopened this Jun 9, 2017
@brokkr brokkr removed the wontfix label Jun 13, 2017
@brokkr
Copy link
Owner Author

brokkr commented Jun 13, 2017

However... if we eschew metadata and limt ourselves to feed/entry data, the implications are nicely limited to entryinfo.py. All we need to do is change poca_abspath using information from sub and entry which are already present in entryinfo.

Misigivings: It's going in a new and 'artificial' direction, similar to track numbering (except we can't use those trracknumbers!)

The cleanest way of doing it is writing dates-title.

@brokkr brokkr added this to the 1.0 milestone Jul 18, 2017
@brokkr
Copy link
Owner Author

brokkr commented Oct 31, 2017

I also don't much like parsing a string for variables interspersed with characters. But... What if we used the lxml to allow users to build-a-string? Something like this:

<rename divider="_">
    <pubdate></pubdate>
    <org_filename></org_filename>
    <subscription_title></subscription_title>
    <string>something</string>
    <tracknumber></tracknumber>
</rename>

Note that tracknumber would be arbitrary number as we do not have the file at the time this is determined. If tracknumber is enabled for metadata, this would use the same setting. If not it would implement it.

would use the format YYYYMMDD so as to enable correct alphabetical order.

The idea would be that we have the tools in place to ensure that the format does not get messed with. Bad xml gets rejected. Anything we don't need (node.text, subnodes), we can just ignore. We process the nodes one by one in the order they come. Each correct node calls a lambda or small function that returns the relevant information which gets added to a growing string. We can call each segment as many times as we want. If a node is not recognised as valid (not quite sure how best to do this) we just skip it.

@brokkr
Copy link
Owner Author

brokkr commented Oct 31, 2017

Ideas:

  • Rather than adding the 'variables' to a string we append them to a list, then join it with divider at the end
  • Rather than creating a dictionary and then hunt for the variables, we simply use the correct attribute names and use getattr to return it. If the attribute is not there, return False (to fail) or None (to bypass).
  • Main issue is having attribute names that match the tag names. May require rewriting some config/entryinfo stuff.

@brokkr
Copy link
Owner Author

brokkr commented Nov 3, 2017

Implemented. We still need to

  1. Check that entries from jar are not subjected to rename(). This could retroactively 'rename' the entry in the db but would not reflect the actual filename on disk.
  2. Test a lot of feeds
  3. poca-subscribe?
  4. Documentation

@brokkr
Copy link
Owner Author

brokkr commented Nov 3, 2017

Also: How do defaults and sub specific renames stack up? I fear that they're just added on top of another, rather than the latter replacing the former.

@brokkr
Copy link
Owner Author

brokkr commented Nov 6, 2017

  1. Only non-expanded entries are expanded
  2. Rename does not stack with defaults
  3. All elements are working as intended
  4. Filenames are somewhat-sanitized. Possibly not fool-proof. Time will tell.

@brokkr brokkr closed this as completed Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant