tkmcclellan / kocha

Kocha - Black Tea - A tool for reading manga.
MIT License
1 stars 0 forks source link

Proposal: Modify download modes #5

Open tkmcclellan opened 2 years ago

tkmcclellan commented 2 years ago

I think we should change the download modes. Dynamic and All will remain the same, but there's not really any value in the None type. So instead, let's make that something like "selective" or "selected" where the user has to enter what chapter/range of chapters they want to download while adding the manga. I'm thinking of using Python-like ranges to do this. so something like:

2 - chapter 2 2:10 - chapters 2 through 10 :10 - all chapters up until 10 10: - all chapters including and after 10

Plus, we can also allow for multiple ranges to be selected. just do the same thing as above but separate them by commas. so

2:5,10:20 - chapters 2 through 5 and 10 through 20.

Ultimately this will end up with inputs in the form of a comma-separated list of ranges/individual chapters. so the input should first be split by comma and then each range/chapter will be processed individually.

Adding multiple ranges will allow for overlapping ranges, and that's no problem. What we will need to do though is find some way of managing and merging ranges. Perhaps creating a Range struct that has a Merge function that allows you to merge two ranges? Not sure of exactly what to do here, it's tricky. A range should also have a function for generating a list of numbers within the range for downloading chapters and a method for detecting if a number is in the range.

Also, chapters in the selected mode will be downloaded dynamically like they are in the dynamic mode, but we shouldn't remove them after they're read or if they're out of the reading range.

tkmcclellan commented 2 years ago

After thinking about it a bit more, perhaps each range should only have up to two parts to it: a beginning and an end. It must have at least one of these two, otherwise what would be the point of selective ranges? So, instead of trying to merge ranges together and getting into unnecessary complexity, perhaps we should have some sort of struct like "RangeCollection" that contains a list of ranges and members to interact with them. Perhaps we could have an Add member that adds a range to the list of ranges. It could also add ranges using insertion sort (that's probably the only way to do it since these are complex data types and not just simple values, and also I can't imagine there being enough ranges used in any selection to where the sorting algorithm will really matter). Of course in that case we should probably use some form of collection that is easily concatenated. We could also have another member on that struct that, given a maximum value, returns a list of integers that the struct cover. That would make it relatively easy to download selected chapters.

tkmcclellan commented 2 years ago

Also add latest download mode so the user can just download the latest chapter