Comments (2)
Currently, this is the implementation:
def generate_episode_filter(episodes):
"""
parse the episode specification string to generate a filter function.
read the docs for understanding the syntax.
:param episodes: the episode specification string
:return: filter function for the episodes
"""
# if no episodes where specified - the generated filter should return false.
if not episodes:
def default_filter():
return False
return default_filter
parsed = []
for token in episodes.split(","):
sub = token.split("-")
bounds = float(sub[0]), float(sub[int(len(sub) is 2)])
parsed.append(bounds)
def generated_filter(episode):
return any(map(lambda bound: bound[0] <= float(episode["episode"]) <= bound[1], parsed))
return generated_filter
I believe that introducing regex solely for this would be over engineering the solution.
from horrible-downloader.
I understand writing that whole thing into that small code that actually works for the current state of the program may be a bit ugly, but here's my honest opinion. Although I'm not very good nor experienced at Python, after reading through the whole code, that part of it that you just showed me with lines 108 and 109 are the ones I understand the least (all those filters seem to me that are just a short way to make some exclusive comparisons, but to me are still non-inmediate). I see you know what you're doing, but maybe you're also trying too hard there to keep code extremely short at the cost of readability (and possibly functionality as well, about what we're mentioning).
I repeat, I really don't understand exactly everything that code is doing, but I kind of can see what you're going for and I think adding some lines of code to make everything more readable and even add more functionality would be a good idea. I'm not saying my implementation is the best - I'm sure you can find a better way to put it there in less or more organized lines - but it doesn't look like over engineering to me, even less when there's no current solution to compare it to.
from horrible-downloader.
Related Issues (20)
- Error parsing non-float episodes HOT 5
- get_episodes(show: str, limit) is not limiting the correct number of episodes HOT 1
- UnicodeDecodeError: 'charmap' HOT 2
- NoneType' object is not subscriptable HOT 9
- IndexError when downloading batch only shows
- Order download priority of new episodes HOT 1
- Adding log output
- Add path to config flag
- Downloading is reversed
- Handle resolution per show
- Error webtorrent not found HOT 1
- support search method
- subscribing to downloaded shows
- implement getlast method
- Can't download new episode by using CLI. (TypeError) HOT 4
- Limit not working properly HOT 1
- change title fuzzing scorer for better results HOT 1
- Add support for local torrent client or exporting magnet links HOT 2
- Search confusion with shows containing another show name. HOT 2
- RIP HS HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from horrible-downloader.