Choosing download location for youtube-dl python - python-3.x

I'm using youtube-dl for a discord bot in python and it works fine, however it downloads the files to the root directory of the project. Since it will be downloading LOTS of videos, I would prefer for it to download to a directory inside of the root. How do I do this?
These are my current options:
ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'reactrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_addreacs': '0.0.0.0', # bind to ipv4 since ipv6 addreacses cause issues sometimes
'output': r'youtube-dl'
}
ffmpeg_options = {
'before_options': '-nostdin',
'options': '-vn'
}

Set an output template containing slashes in the outtmpl option:
ytdl_format_options = {
'outtmpl': 'somewhere/%(extractor_key)s/%(extractor)s-%(id)s-%(title)s.%(ext)s',
...
}
Output templates can have lots of fields (including playlist IDs, license, format name/bitrates, album name & much more, depending on what the video website you're using supports). For more information, refer to the youtube-dl documentation of output templates. All fields can be used as directory or file names.

Related

RethinkDB pub/sub ReqlPermissionError

I'm using Publish-Subscribe with RethinkDB.
For exchange I use one db named 'RPI_messages' with three tables:
Connector_messages
MAC_messages
Orders
I want to introduce some basic authentication on producer and consumer sides like this:
r.db('rethinkdb').table('users').insert({id: 'lis', password: 'somepassword'})
r.db('rethinkdb').table('users').insert({id: 'rpi', password: 'someotherpassword'})
r.db('RPi_messages').grant('lis', {read: false, write: true, config: true}) //producer
r.db('RPi_messages').grant('rpi', {read: true, write: false, config: true}) //consumers
r.db('rethinkdb').table('permissions')
shows this:
{
"database": "RPi_messages" ,
"id": [
"lis" ,
"007928e5-c654-4311-b3aa-a834c62dcf88"
] ,
"permissions": {
"config": true ,
"read": false ,
"write": true
} ,
"user": "lis"
}
Problem:
When I try to publish or to subscribe to exchange it throws an exception:
ReqlPermissionError: User `lis` does not have the required `config` permission in:
r.db_create('RPi_messages')
rethinkdb.errors.ReqlPermissionError: User `rpi` does not have the required `config` permission in:
r.db_create('RPi_messages')
Does this mean that my users need to have global permissions?
Any help greatly appreciated.
So, with fairly bit of try and error I made it work.
For anyone else: You need config permission on global scope for every user in your pub-sub system like this:
r.grant('lis', {read: false, write: false, config: true});
r.grant('rpi', {read: false, write: false, config: true});
...and following permissions on table(s) or, in my case, on database scope:
r.db('RPi_messages').grant('lis', {read: true, write: true, config: true}); //publisher
r.db('RPi_messages').grant('rpi', {read: true, write: false, config: true}); //sunscriber
Correct me if I'm wrong but this doesn't look very secure to me. Those permissions are needed because Exchanger class in rethink's pub-sub system looks if exchange table exists and creates on if it doesn't. Which means that anyone who gets one of your client subscriber devices can create as many tables in your db as they want.

How to to globally disable E501 in VSCODE and pylama

I am using Visual Studio Code and pylama linter.
Currently I am added # noqa to every long line to avoid the following linter message:
line too long (100 > 79 characters) [pycodestyle]pylama(E501)
I've added "--disable=E501" to VSCODE's workspace settings.json file as shown below:
{
"editor.tabSize": 2,
"editor.detectIndentation": false,
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": false,
"python.linting.pycodestyleEnabled": false,
"python.linting.pylamaEnabled": true,
"[python]": {
"editor.tabSize": 4
},
"python.linting.pylama": [
"--disable=E501"
]
}
but still I get E501.
How can I disable E501 in my VSCODE workspace for good?
For other linters, the .settings file seems to be looking for
python.linting.<linter>Args
so I recommend trying:
"python.linting.pylamaArgs": [
"--ignore=E501"
]
or potentially
python.linting.pylamaArgs": ["--disable=E501"]
See also: https://code.visualstudio.com/docs/python/settings-reference#_pylama
that seems to suggest the same:
pylamaArgs [] Additional arguments for pylama, where each top-level element that's separated by a space is a separate item in the list.

Suppressing nightwatchjs warnings in terminal output

I'm using nightwatchjs to run my test suite, and I would like to remove the warning messages being outputted to my terminal display.
At the moment, I'm getting loads of these (admittedly genuine) warning messages whilst my scripts are running and it's making the reading of the results harder and harder.
As an example;
Yes they are valid messages, but it's not often possible for me to uniquely pick out each individual element and I'm not interested in them for my output.
So, I'd like to know how I can stop them from being reported in my terminal.
Below is what I've tried so far in my nightwatch.conf.js config file;
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled : true,
acceptSslCerts: true,
acceptInscureCerts: true,
chromeOptions : {
args: [
'--ignore-certificate-errors',
'--allow-running-insecure-content',
'--disable-web-security',
'--disable-infobars',
'--disable-popup-blocking',
'--disable-notifications',
'--log-level=3'],
prefs: {
'profile.managed_default_content_settings.popups' : 1,
'profile.managed_default_content_settings.notifications' : 1
},
},
},
},
but it's still displaying the warnings.
Any help on this would be really appreciated.
Many thanks.
You can try setting detailed_output property to false in the configuration file. This should stop these details from printing in the console.
You can find a sample config file here.
You can find relevant details available under Output Settings section of official docs here.
Update 1: This looks like a combo of properties which controls this and the below combo works for me.
live_output: false,
silent: true,
output: true,
detailed_output: false,
disable_error_log: false,

Specify subtitle options while downloading YouTube subtitles only using youtube-dl

I want to download the subtitle of a YouTube playlist with the following specifications:
Only in English
In srt format
Just the subtitles files and not the video itself
I have tried the following code snippet. But it is downloading the subtitles in all available languages and in vtt format.
ydl_opts = {
'allsubtitles': True,
'writesubtitles': True,
'convertsubtitles':True,
'skip_download':True,
'outtmpl': 'C:/Users/shrayani.mondal/Desktop/Personal/Python Projects/Speech to text/Subtitles/%(title)s.%(ext)s',
#'subtitlesformat': 'srt'
'subtitleslangs':'en',
'postprocessors': [{
'key': 'FFmpegSubtitlesConvertor',
'format': 'srt',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=Lp7E973zozc&list=PLQltO7RlbjPJnbfHLsFJWP-DYnWPugUZ7'])
My second objective is to use auto-generated English subtitles for videos that do not have subtitles available. How do I include the if statement for that?
# if convert vtt into srt:
# use postprocessors code snippet given below
ytdlp_option = {
"progress_hooks": [self.track_progress],
"logger": DownloadVideo.Logger(self),
"noplaylist": True,
"format": f'{self.selected_file.get(VIDEO, {}).get("format_id")}+{self.selected_file.get(AUDIO, {}).get("format_id")}',
"paths": {"home": self.video_download_path},
"outtmpl": {"default": f"{self.video_file_path}.{self.output_extension}"},
"postprocessors": [
{
"key": "FFmpegSubtitlesConvertor",
"format": "srt",
}
]
"writesubtitles": True,
"subtitlesformat": "vtt"
"subtitleslangs": ["en"],
}
you can download subtitle only use this way.
youtube-dl --write-sub --write-auto-sub --skip-download YOURLINK
Default download subtitle language is Eng.
more option have in this link or youtube-dl --help (enter link description here
default subtitle format is vtt. can you convert to srt. try with youtube-dl or simply convertor have in internet.

Can't Get Require Optimizer to mangle output

I'm using the Require Optimizer to combine all of our source files in to a single file. That works great, but when I try to set optimize: 'uglify' or optimze: 'uglify2' I don't get mangled output: everything is combined in to a single line of a single file, but that line is filled with the original variable names.
I've tried setting various uglifyer options like:
uglify: {no_mangle: false}
or:
uglify2: {mangle: true}
but they don't work. Can anyone explain how I can get the optimizer to mangle its output?
EDIT
Here's my build.js file:
({
baseUrl: ".",
paths: {
template: 'ext/require/hbs',
text: 'ext/require/text'
},
name: "main",
optimize: "uglify",
out: "../built/main-built.js",
uglify: {
beautify: false,
space_colon: true,
no_mangle: false,
}
})
I wound up fixing this by updating our copy of Require.

Resources