-
Notifications
You must be signed in to change notification settings - Fork 22
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
Trying to fix the .m3u decoding problem #16
Conversation
Are you sure it is working for all kind of variance of m3u playlists? The for loop was there for a reason. I mean if you have an advanced formatted m3u playlist, multiple first lines will have a
Tested with your changes:
|
Hmm, strange, maybe mine where resolved differently? I don't see a reason why that would be the case... I'm currently using radiorec on Ubuntu 20.04... |
I changed the code to store the HTTPResponse object in remotefile and iterate over the lines |
… wrong urls. Also changed the url of wdr3.
Added the mentioned checks. Maybe writing some tests would be good in the long run... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution. I'd a look on it and proposed some improvements to have a better control if the application is used by an automatism / script.
radiorec.py
Outdated
break | ||
streamurl = tmpstr | ||
if not len(tmpstr) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python allows to just check on if tmpstr
(see https://onlinegdb.com/3tujtNGvK)
remotefile = pool.request('GET', streamurl) | ||
except MaxRetryError: | ||
print('The URL of the station is not found! Check' + args.station + ' in the Settings!') | ||
sys.exit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors should be indicated with a positive number (e.g. sys.exit(1)
) as this status can be checked by other scripts.
radiorec.py
Outdated
try: | ||
remotefile = pool.request('GET', streamurl) | ||
except MaxRetryError: | ||
print('The URL of the station is not found! Check' + args.station + ' in the Settings!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors should be indicated to stderr, not stdout. With this you're able to filter out the debug messages or info messages if you just would like to extract the errors (e.g. for sending automatically reports via scripts).
So i recommend to get a log object (via logging.getLogger(__name__)
) and log it with error
function.
E.g.:
logging.getLogger(__name__).error('The URL of the station is somehow faulty! Check' + args.station + ' in the Settings!')
Would do this for this line as well as line 134.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+line 142 + line 150
radiorec.py
Outdated
|
||
verboseprint(print_time() + " ... Stream URL: " + streamurl) | ||
target_dir = os.path.expandvars(settings['GLOBAL']['target_dir']) | ||
if not os.path.isdir(target_dir + os.sep): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why + os.sep
?
Furthermore we could (at least) try to create the directory with os.makedirs
prior this check with exist_ok=True
…of the Target Directory, and some PEP8 Styling things too..
I included your mentions! Hope its okay now! Frohe Weihnachten! |
@gjelsas Thanks for your contribution. For me it looks good (although I couldn't test it thoroughly). |
This is a easy fix for this Issue. The current Code is not storing anything in
streamurl