-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
99 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
import re | ||
|
||
|
||
class YdlLogger(object): | ||
rv = None | ||
|
||
def __init__(self, rv, index): | ||
self.rv = rv | ||
self.index = index | ||
|
||
def debug(self, msg): | ||
m = re.search(r'\[download\][ ]+(\d+\.\d+)% of (~?\d+\.\d+).* at[ ]+(.*) ETA (\d+\:\d+)', msg) | ||
|
||
if m is not None: | ||
self.rv.data[self.index]['percent'] = float(m.group(1)) | ||
self.rv.data[self.index]['file_size'] = m.group(2) | ||
self.rv.data[self.index]['speed'] = m.group(3) | ||
self.rv.data[self.index]['ETA'] = m.group(4) | ||
self.rv.refresh_from_data() | ||
else: | ||
self.rv.data[self.index]['log'] += f"{msg}\n" | ||
self.rv.refresh_from_data() | ||
|
||
def warning(self, msg): | ||
self.rv.data[self.index]['log'] += f"[color=ffff00]{msg}[/color]\n" | ||
self.rv.refresh_from_data() | ||
|
||
def error(self, msg): | ||
self.rv.data[self.index]['log'] += f"[color=ff0000]{msg}[/color]\n" | ||
self.rv.refresh_from_data() | ||
rv = None | ||
|
||
def __init__(self, rv, index): | ||
self.rv = rv | ||
self.index = index | ||
|
||
def debug(self, msg): | ||
m = re.search( | ||
r'\[download\][ ]+(\d+\.\d+)% of (~?\d+\.\d+.*) at[ ]+(.*) ETA (\d+\:\d+)', msg) | ||
|
||
if m is not None: | ||
self.rv.data[self.index]['percent'] = float(m.group(1)) | ||
self.rv.data[self.index]['file_size'] = m.group(2) | ||
self.rv.data[self.index]['speed'] = m.group(3) | ||
self.rv.data[self.index]['ETA'] = m.group(4) | ||
else: | ||
self.rv.data[self.index]['log'] += f"{msg}\n" | ||
if msg.endswith('has already been downloaded'): | ||
self.rv.data[self.index]['percent'] = 100 | ||
self.rv.data[self.index]['ETA'] = 'This video has alderly been downloaded' | ||
|
||
self.rv.refresh_from_data() | ||
|
||
def warning(self, msg): | ||
self.rv.data[self.index]['log'] += f"[color=ffff00]{msg}[/color]\n" | ||
self.rv.refresh_from_data() | ||
|
||
def error(self, msg): | ||
self.rv.data[self.index]['log'] += f"[color=ff0000]{msg}[/color]\n" | ||
self.rv.refresh_from_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters