Skip to content

Commit

Permalink
Merge pull request #38 from zaharcelac/master
Browse files Browse the repository at this point in the history
Several bug fixes
  • Loading branch information
d0u9 authored Mar 3, 2021
2 parents 8d3871b + b6903a1 commit a33cd69
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
4 changes: 3 additions & 1 deletion example_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
},
"youtube_dl": {
"format": "bestaudio/best",
"proxy": "socks5://127.0.0.1:1080"
"proxy": "socks5://127.0.0.1:1080",
"ratelimit": 1097152,
"outtmpl": "%(title)s.%(ext)s"
}
}
3 changes: 3 additions & 0 deletions youtube_dl_webui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def load(self, conf_dict):
# More check can be made here
if key in conf_dict:
self._conf[key] = conf_dict[key] if func is None else func(conf_dict.get(key, dft_val))
self._conf[key] = int(self._conf[key]) if val_type == 'int' else self._conf[key]
elif dft_val is not None:
self._conf[key] = dft_val if func is None else func(conf_dict.get(key, dft_val))

Expand All @@ -51,6 +52,8 @@ class ydl_conf(conf_base):
#(key, default_val, type, validate_regex, call_function)
('proxy', None, 'string', None, None),
('format', None, 'string', None, None),
('ratelimit', 1048576, 'int', None, None),
('outtmpl', None, 'string', None, None),
]

_task_settable_fields = set(['format'])
Expand Down
2 changes: 1 addition & 1 deletion youtube_dl_webui/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def delete_task(self, tid):
if row is None:
raise TaskInexistenceError('')

dl_file = row['filename']
dl_file = row['filename'] if len(row['filename']) > 0 else None

self.db.execute('DELETE FROM task_status WHERE tid=(?)', (tid, ))
self.db.execute('DELETE FROM task_info WHERE tid=(?)', (tid, ))
Expand Down
5 changes: 4 additions & 1 deletion youtube_dl_webui/static/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var videoDownload = (function (Vue, extendAM){
modalData: {
add: { url: '', ydl_opts: {} },
remove: { removeFile: false },
preference: {youtube_dl: {fomart: '', proxy: ''}, general: {download_dir: '', db_path: '', log_size: ''}},
preference: {youtube_dl: {fomart: '', proxy: ''}, general: {download_dir: '', db_path: '', log_size: '', ratelimit: '', outtmpl: ''}},
},
currentSelected: null,
taskDetails: {},
Expand Down Expand Up @@ -96,6 +96,7 @@ var videoDownload = (function (Vue, extendAM){
}, function(err){
_self.showAlertToast(err, 'error');
});
_self.showModal = false;
},
removeTask: function(){
var _self = this;
Expand Down Expand Up @@ -157,6 +158,8 @@ var videoDownload = (function (Vue, extendAM){
_self.modalData.preference.general.log_size = config.general.log_size;
_self.modalData.preference.youtube_dl.format = config.youtube_dl.format;
_self.modalData.preference.youtube_dl.proxy = config.youtube_dl.proxy;
_self.modalData.preference.youtube_dl.ratelimit = config.youtube_dl.ratelimit;
_self.modalData.preference.youtube_dl.outtmpl = config.youtube_dl.outtmpl;
}
});
},
Expand Down
2 changes: 1 addition & 1 deletion youtube_dl_webui/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def delete_task(self, tid, del_file=False):
except TaskInexistenceError as e:
raise TaskInexistenceError(e.msg)

if del_file and dl_file is not None:
if del_file and dl_file is not None and len(dl_file) > 0:
file_wo_ext, ext = dl_file, None
while ext != '':
file_wo_ext, ext = os.path.splitext(file_wo_ext)
Expand Down
18 changes: 14 additions & 4 deletions youtube_dl_webui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@
<hr class="left-hr" /><span style="font-weight: bold;">General</span><hr class="right-hr" />
</div>
<div>
<label>Download Path:</label><input type="text" ref="dl-path" v-model="modalData.preference.general.download_dir" v-cloak @keyup.enter="addTask" @keyup.esc="showModal = false"/>
<label>Download Path:</label><input type="text" ref="dl-path" v-model="modalData.preference.general.download_dir" v-cloak @keyup.esc="showModal = false"/>
</div>
<div>
<label>Database Path:</label><input type="text" ref="db-path" v-model="modalData.preference.general.db_path" v-cloak @keyup.enter="addTask" @keyup.esc="showModal = false"/>
<label>Database Path:</label><input type="text" ref="db-path" v-model="modalData.preference.general.db_path" v-cloak @keyup.esc="showModal = false"/>
</div>
<div>
<label>Log Size:</label><input type="text" ref="log-size" v-model="modalData.preference.general.log_size" v-cloak @keyup.enter="addTask" @keyup.esc="showModal = false"/>
<label>Log Size:</label><input type="text" ref="log-size" v-model="modalData.preference.general.log_size" v-cloak @keyup.esc="showModal = false"/>
</div>
<div style="text-align:center;">
<hr class="left-hr" /><span style="font-weight: bold;">youtube-dl options</span><hr class="right-hr" />
Expand All @@ -135,7 +135,17 @@
<div>
<label>Proxy:</label><input type="text" ref="proxy" v-model="modalData.preference.youtube_dl.proxy" v-cloak @keyup.esc="showModal = false"/>
</div>
<div>
<label>Out Tmpl:</label><input type="text" ref="outtmpl" v-model="modalData.preference.youtube_dl.outtmpl" v-cloak @keyup.esc="showModal = false"/>
</div>
<div>
<label>Rate Limit:</label><input type="text" ref="ratelimit" v-model="modalData.preference.youtube_dl.ratelimit" v-cloak @keyup.esc="showModal = false"/>
</div>
</div>
<div slot="footer">
<button class="modal-default-button" @click="updatePreference" style="width:auto;">save</button>
<button class="modal-default-button" @click="showModal = false" style="width:auto;">cancel</button>
</div>
</template>
<template v-if="modalType === 'about'">
<div slot="header">About</div>
Expand All @@ -162,7 +172,7 @@
<div slot="footer">
<button class="modal-default-button" @click="showModal = false">cancel</button>
<button class="modal-default-button" @click="removeData" style="width:auto;">remove with data</button>
<button class="modal-default-button" @click="removeTask">remove task</button>
<button class="modal-default-button" @click="removeTask" style="width:auto;">remove task</button>
</div>
</template>
<template v-if="modalType === 'addTask'">
Expand Down
3 changes: 2 additions & 1 deletion youtube_dl_webui/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def run(self):

# self.logger.debug(json.dumps(info_dict, indent=4))

info_dict['description'] = info_dict['description'].replace('\n', '<br />');
if "description" in info_dict:
info_dict['description'] = info_dict['description'].replace('\n', '<br />');
payload = {'tid': self.tid, 'data': info_dict}
self.msg_cli.put('info_dict', payload)

Expand Down

0 comments on commit a33cd69

Please sign in to comment.