Linter and misc cleanup

:ci skip dl
This commit is contained in:
pukkandan 2021-01-29 01:02:37 +05:30
parent 64c0d954e5
commit 66c935fb16
11 changed files with 70 additions and 93 deletions

View file

@ -25,8 +25,8 @@ jobs:
run: sudo apt-get -y install zip pandoc man
- name: Bump version
id: bump_version
run: python scripts/update-version-workflow.py
- name: Check the output from My action
run: python devscripts/update-version-workflow.py
- name: Check the version
run: echo "${{ steps.bump_version.outputs.ytdlc_version }}"
- name: Run Make
run: make
@ -86,7 +86,7 @@ jobs:
- name: Install Requirements
run: pip install pyinstaller
- name: Bump version
run: python scripts/update-version-workflow.py
run: python devscripts/update-version-workflow.py
- name: Run PyInstaller Script
run: python pyinst.py
- name: Upload youtube-dlc.exe Windows binary
@ -121,7 +121,7 @@ jobs:
- name: Install Requirements for 32 Bit
run: pip install pyinstaller==3.5
- name: Bump version
run: python scripts/update-version-workflow.py
run: python devscripts/update-version-workflow.py
- name: Run PyInstaller Script for 32 Bit
run: python pyinst32.py
- name: Upload Executable youtube-dlc_x86.exe

87
.gitignore vendored
View file

@ -1,35 +1,43 @@
# Python
*.pyc
*.pyo
*.class
*~
*.DS_Store
wine-py2exe/
py2exe.log
*.kate-swp
build/
dist/
zip/
tmp/
venv/
# Misc
*~
*.DS_Store
*.kate-swp
MANIFEST
README.txt
youtube-dl.1
youtube-dlc.1
youtube-dl.bash-completion
youtube-dlc.bash-completion
youtube-dl.fish
youtube-dlc.fish
youtube_dl/extractor/lazy_extractors.py
youtube_dlc/extractor/lazy_extractors.py
youtube-dl
youtube-dlc
youtube-dl.exe
youtube-dlc.exe
youtube-dl.tar.gz
youtube-dlc.tar.gz
youtube-dlc.spec
test/local_parameters.json
.coverage
cover/
updates_key.pem
*.egg-info
.tox
*.class
# Generated
README.txt
*.1
*.bash-completion
*.fish
*.exe
*.tar.gz
*.zsh
*.spec
# Binary
youtube-dl
youtube-dlc
*.exe
# Downloaded
*.srt
*.ttml
*.sbv
@ -46,32 +54,29 @@ updates_key.pem
*.swf
*.part
*.ytdl
*.conf
*.swp
*.ogg
*.opus
# Config
*.conf
*.spec
*.exe
test/local_parameters.json
.tox
youtube-dl.zsh
youtube-dlc.zsh
# IntelliJ related files
.idea
*.iml
tmp/
venv/
# VS Code related files
.vscode
# SublimeText files
*.sublime-workspace
# Cookies
cookies
cookies.txt
# Text Editor / IDE
.idea
*.iml
.vscode
*.sublime-workspace
*.sublime-project
!yt-dlp.sublime-project
# Lazy extractors
*/extractor/lazy_extractors.py
# Plugins
ytdlp_plugins/extractor/*
!ytdlp_plugins/extractor/__init__.py

View file

@ -1,8 +1,11 @@
from __future__ import unicode_literals
from datetime import datetime
# import urllib.request
# response = urllib.request.urlopen('https://blackjack4494.github.io/youtube-dlc/update/LATEST_VERSION')
# _LATEST_VERSION = response.read().decode('utf-8')
exec(compile(open('youtube_dlc/version.py').read(), 'youtube_dlc/version.py', 'exec'))
_LATEST_VERSION = locals()['__version__']
_OLD_VERSION = _LATEST_VERSION.replace('-', '.').split(".", 4)

View file

@ -1,33 +0,0 @@
# Unused
from __future__ import unicode_literals
from datetime import datetime
import urllib.request
response = urllib.request.urlopen('https://blackjack4494.github.io/youtube-dlc/update/LATEST_VERSION')
_LATEST_VERSION = response.read().decode('utf-8')
_OLD_VERSION = _LATEST_VERSION.rsplit("-", 1)
if len(_OLD_VERSION) > 0:
old_ver = _OLD_VERSION[0]
old_rev = ''
if len(_OLD_VERSION) > 1:
old_rev = _OLD_VERSION[1]
now = datetime.now()
# ver = f'{datetime.today():%Y.%m.%d}'
ver = now.strftime("%Y.%m.%d")
rev = ''
if old_ver == ver:
if old_rev:
rev = int(old_rev) + 1
else:
rev = 1
_SEPARATOR = '-'
version = _SEPARATOR.join(filter(None, [ver, str(rev)]))

View file

@ -2,5 +2,5 @@
universal = True
[flake8]
exclude = youtube_dlc/extractor/__init__.py,devscripts/buildserver.py,devscripts/lazy_load_template.py,devscripts/make_issue_template.py,setup.py,build,.git,venv,devscripts/create-github-release.py,devscripts/release.sh,devscripts/show-downloads-statistics.py,scripts/update-version.py
exclude = youtube_dlc/extractor/__init__.py,devscripts/buildserver.py,devscripts/lazy_load_template.py,devscripts/make_issue_template.py,setup.py,build,.git,venv,devscripts/create-github-release.py,devscripts/release.sh,devscripts/show-downloads-statistics.py
ignore = E402,E501,E731,E741,W503

View file

@ -41,10 +41,8 @@ else:
params = {
'data_files': data_files,
}
#if setuptools_available:
params['entry_points'] = {'console_scripts': ['youtube-dlc = youtube_dlc:main']}
#else:
# params['scripts'] = ['bin/youtube-dlc']
class build_lazy_extractors(Command):
description = 'Build the extractor lazy loading module'
@ -62,6 +60,9 @@ class build_lazy_extractors(Command):
dry_run=self.dry_run,
)
packages = find_packages(exclude=("youtube_dl","test",))
setup(
name="yt-dlp",
version=__version__,
@ -71,7 +72,7 @@ setup(
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
url="https://github.com/pukkandan/yt-dlp",
packages=find_packages(exclude=("youtube_dl","test",)),
packages=packages,
project_urls={
'Documentation': 'https://github.com/pukkandan/yt-dlp#yt-dlp',
'Source': 'https://github.com/pukkandan/yt-dlp',

View file

@ -1119,15 +1119,15 @@ class YoutubeDL(object):
if not ensure_dir_exists(encodeFilename(infofn)):
return
if self.params.get('overwrites', True) and os.path.exists(encodeFilename(infofn)):
self.to_screen('[info] Playlist description metadata is already present')
self.to_screen('[info] Playlist metadata is already present')
else:
self.to_screen('[info] Writing description playlist metadata as JSON to: ' + infofn)
self.to_screen('[info] Writing playlist metadata as JSON to: ' + infofn)
playlist_info = dict(ie_result)
playlist_info.pop('entries')
try:
write_json_file(self.filter_requested_info(playlist_info), infofn)
except (OSError, IOError):
self.report_error('Cannot write playlist description metadata to JSON file ' + infofn)
self.report_error('Cannot write playlist metadata to JSON file ' + infofn)
if self.params.get('writedescription', False):
descfn = replace_extension(
@ -2144,13 +2144,13 @@ class YoutubeDL(object):
if not ensure_dir_exists(encodeFilename(infofn)):
return
if not self.params.get('overwrites', True) and os.path.exists(encodeFilename(infofn)):
self.to_screen('[info] Video description metadata is already present')
self.to_screen('[info] Video metadata is already present')
else:
self.to_screen('[info] Writing video description metadata as JSON to: ' + infofn)
self.to_screen('[info] Writing video metadata as JSON to: ' + infofn)
try:
write_json_file(self.filter_requested_info(info_dict), infofn)
except (OSError, IOError):
self.report_error('Cannot write metadata to JSON file ' + infofn)
self.report_error('Cannot write video metadata to JSON file ' + infofn)
return
info_dict['__infojson_filepath'] = infofn

View file

@ -31,6 +31,7 @@ try:
except ImportError:
NFLTokenGenerator = None
def md5_text(s):
if not isinstance(s, compat_str):
s = compat_str(s)

View file

@ -2492,8 +2492,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
def get_continuation(continuation, session_token, replies=False):
query = {
'pbj': 1,
'ctoken': continuation,
'pbj': 1,
'ctoken': continuation,
}
if replies:
query['action_get_comment_replies'] = 1

View file

@ -153,7 +153,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
elif info['ext'] in ['ogg', 'opus']:
if not _has_mutagen:
raise EmbedThumbnailPPError('module mutagen was not found. Please install.')
raise EmbedThumbnailPPError('module mutagen was not found. Please install')
size_regex = r',\s*(?P<w>\d+)x(?P<h>\d+)\s*[,\[]'
size_result = self.run_ffmpeg(thumbnail_filename, thumbnail_filename, ['-hide_banner'])
mobj = re.search(size_regex, size_result)