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

Editorconfig & Format chapter number to %03d #30

Merged
merged 6 commits into from
Jan 5, 2017
Merged

Editorconfig & Format chapter number to %03d #30

merged 6 commits into from
Jan 5, 2017

Conversation

kuanyui
Copy link
Contributor

@kuanyui kuanyui commented Jan 4, 2017

For #22
Sorry for late. Too busy recently.

@eight04
Copy link
Owner

eight04 commented Jan 4, 2017

I am going to make an option for this.

@eight04
Copy link
Owner

eight04 commented Jan 4, 2017

To apply number format, add following to setting.ini:

[動漫屋]
titlenumberformat = {:03d}

@kuanyui
Copy link
Contributor Author

kuanyui commented Jan 5, 2017

Where is the RegExp pattern 第(\d+)[話话卷]?

def replacer(match):
number = match.group()
return format.format(int(number))
return re.sub("\d+", replacer, title)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may cause wrongly replacement when the title itself contains digits.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should try to trim the mission title from the episode title first?

Some title examples:

泰安路47号 第006回
http://www.dm5.com/manhua-taianlu-47-hao/

原作版108(7)
第28-29話
http://tw.ikanman.com/comic/9637/

Copy link
Contributor Author

@kuanyui kuanyui Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every site has different rules, so I use 第(\d+)[話话卷]? such a conservative pattern. Or maybe each site has its own digits formatter?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding new API to format title is the safest, but let's consider if there is an universal solution first.

With above solution,

泰安路47号 第006回
原作版108(7)
第28-29話

becomes

泰安路47号 第006回
原作版108(007)
第028-029話

which looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look of this extreme example: http://www.dm5.com/manhua-bianchengnageta/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://i.imgur.com/LzP609B.png
I didn't see the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my fault. I misunderstood something.

@kuanyui
Copy link
Contributor Author

kuanyui commented Jan 5, 2017

Awesome! I think it's time to merge this PR.

BTW, Your skill in Python is so good, I never know thatre.sub() can accept a function as parameter (Seldom see functional programming in Python, though I think that's due to my poor experience...) Reading your code teaches me so much. Thank you :)

@eight04 eight04 merged commit 65353af into eight04:master Jan 5, 2017
@eight04
Copy link
Owner

eight04 commented Jan 5, 2017

Released in 2017.1.6.

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

Successfully merging this pull request may close these issues.

2 participants