Skip to content

Commit

Permalink
Merge branch 'master' into master-32445
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf authored Jul 18, 2023
2 parents 47214e4 + e2a8e7e commit 9ff5511
Show file tree
Hide file tree
Showing 6 changed files with 525 additions and 117 deletions.
39 changes: 39 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[![Build Status](https://github.com/ytdl-org/youtube-dl/workflows/CI/badge.svg)](https://github.com/ytdl-org/youtube-dl/actions?query=workflow%3ACI)


**This repository is for youtube-dl nightly builds.**

youtube-dl - download videos from youtube.com or other video platforms

- [INSTALLATION](#installation)
- [DESCRIPTION](#description)
- [MORE INFORMATION](#more-information)
- [COPYRIGHT](#copyright)

# INSTALLATION

These instructions are specific to this nightly release repository. Refer to the [installation instructions](https://github.com/ytdl-org/youtube-dl#installation) for the main repository (the "main instructions" below) for guidance on
* the types of installation available
* installation methods and command lines to adapt for each installation type.

Find the appropriate build to install in the [Releases](https://github.com/ytdl-org/ytdl-nightly/releases) page here, rather than the URLs mentioned in the main instructions. Replace the download URL in the appropriate command line shown in the main instructions with the URL from the Releases page.

These nightly releases are not available through package managers like _brew_.

# DESCRIPTION

**youtube-dl** is a command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is not platform specific. It should work on your Unix box, on Windows or on macOS. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.

youtube-dl [OPTIONS] URL [URL...]

# MORE INFORMATION

For **more information**, or to **raise a support issue**, visit [the main site](https://github.com/ytdl-org/youtube-dl).

Please contribute any pull requests at the main site as well, unless the change is specific to this nightly repository (eg, workflow improvements).

# COPYRIGHT

youtube-dl is released into the public domain by the copyright holders.

This README file is likewise released into the public domain.
220 changes: 220 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
name: Build

on:
workflow_call:
inputs:
build-commit:
type: string
required: true
workflow_dispatch:
inputs:
build-commit:
description: 'SHA of commit being built'
type: string
required: false

jobs:
build_unix:
runs-on: ubuntu-latest
outputs:
version_suffix: ${{ steps.version_suffix.outputs.version_suffix }}
ytdl_version: ${{ steps.bump_version.outputs.ytdl_version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
sha256_bin: ${{ steps.sha256_bin.outputs.sha256_bin }}
sha512_bin: ${{ steps.sha512_bin.outputs.sha512_bin }}
sha256_tar: ${{ steps.sha256_tar.outputs.sha256_tar }}
sha512_tar: ${{ steps.sha512_tar.outputs.sha512_tar }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install packages
run: sudo apt-get -y install zip pandoc man
- name: Bump version
id: bump_version
run: |
ytdl_version=$(python devscripts/update-version.py)
echo "ytdl_version=$ytdl_version" >> "$GITHUB_OUTPUT"
sha=${{ inputs.build-commit }}
sed -i -rn -e '/^ *RELEASE_GIT_HEAD *=/z;$s/$/&'"\nRELEASE_GIT_HEAD = '${sha}'/;p" youtube_dl/version.py
x=${sha#?????????}; sha=${sha%$x}
echo "Version = $ytdl_version${sha+[ }${sha}${sha+]}"
make issuetemplates
- name: Push to release
id: push_release
run: echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Get Changelog
id: get_changelog
run: |
changelog=$(cat Changelog.md | grep -oPz '(?s)(?<=### ${{ steps.bump_version.outputs.ytdl_version }}\n{2}).+?(?=\n{2,3}###)') || true
echo "changelog<<EOF" >> $GITHUB_ENV
echo "$changelog" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Run Make
run: make all tar
- name: Get SHA2-256SUMS for youtube-dl
id: sha256_bin
run: echo "sha256_bin=$(sha256sum youtube-dl | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Get SHA2-256SUMS for youtube-dl.tar.gz
id: sha256_tar
run: echo "sha256_tar=$(sha256sum youtube-dl.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Get SHA2-512SUMS for youtube-dl
id: sha512_bin
run: echo "sha512_bin=$(sha512sum youtube-dl | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Get SHA2-512SUMS for youtube-dl.tar.gz
id: sha512_tar
run: echo "sha512_tar=$(sha512sum youtube-dl.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_version.outputs.ytdl_version }}
release_name: youtube-dl ${{ steps.bump_version.outputs.ytdl_version }}
commitish: ${{ steps.push_release.outputs.head_sha }}
body: This is a nightly build of youtube-dl.
draft: false
prerelease: false
- name: Upload youtube-dl Unix binary
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./youtube-dl
asset_name: youtube-dl
asset_content_type: application/octet-stream
- name: Upload Source tar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./youtube-dl.tar.gz
asset_name: youtube-dl-${{ steps.bump_version.outputs.ytdl_version }}.tar.gz
asset_content_type: application/gzip

build_windows:
runs-on: windows-2022
needs: build_unix
env:
PYCRYPTO: pycrypto-2.6.1-cp34-none-win32
outputs:
sha256_win: ${{ steps.sha256_win.outputs.sha256_win }}
sha512_win: ${{ steps.sha512_win.outputs.sha512_win }}

steps:
- uses: actions/checkout@v3
# reason to choose 3.4: https://media.discordapp.net/attachments/807245652072857613/942409077701619742/unknown.png
- name: Set up Python 3.4
uses: actions/setup-python@v4
with:
python-version: '3.4'
architecture: 'x86'
- name: Install packages
# https://setuptools.pypa.io/en/latest/history.html#v44-0-0
# https://pypi.org/project/py2exe/0.9.2.2/
# https://pip.pypa.io/en/stable/news/#v19-2
# https://wheel.readthedocs.io/en/stable/news.html
run: python -m pip install --upgrade "pip<19.2" "setuptools<44" "wheel<0.34.0" py2exe==0.9.2.2
- name: Bump version
id: bump_version
shell: bash
run: |
ytdl_version=$(python devscripts/update-version.py)
sha=${{ inputs.build-commit }}
sed -i -rn -e '/^ *RELEASE_GIT_HEAD *=/z;$s/$/&'"\nRELEASE_GIT_HEAD = '${sha}'/;p" youtube_dl/version.py
x=${sha#?????????}; sha=${sha%$x}
echo "Version = $ytdl_version${sha+[ }${sha}${sha+]}"
# - name: Run PyInstaller Script
# run: python -m PyInstaller --onefile --console --distpath dist/ -n youtube-dl youtube_dl\__main__.py
- name: Cache PyCrypto
id: cache_pc
uses: actions/cache@v3
with:
key: ${{ env.PYCRYPTO }}
path: ./${{ env.PYCRYPTO }}
- name: Acquire PyCrypto
if: ${{ ! steps.cache_pc.outputs.cache-hit }}
shell: bash
run: |
mkdir -p ./${PYCRYPTO}
cd ${PYCRYPTO}
curl -L -O "https://web.archive.org/web/20200627032153/http://www.voidspace.org.uk/python/pycrypto-2.6.1/pycrypto-2.6.1-cp34-none-win32.whl"
- name: Install PyCrypto
shell: bash
run: |
python -m pip install ./${PYCRYPTO}/${PYCRYPTO}.whl
- name: Build EXE file
run: python setup.py py2exe
- name: Upload youtube-dl.exe Windows binary
id: upload-release-windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build_unix.outputs.upload_url }}
asset_path: ./youtube-dl.exe
asset_name: youtube-dl.exe
asset_content_type: application/vnd.microsoft.portable-executable
- name: Get SHA2-256SUMS for youtube-dl.exe
id: sha256_win
run: echo "sha256_win=$((Get-FileHash youtube-dl.exe -Algorithm SHA256).Hash.ToLower())" >> "$env:GITHUB_OUTPUT"
- name: Get SHA2-512SUMS for youtube-dl.exe
id: sha512_win
run: echo "sha512_win=$((Get-FileHash youtube-dl.exe -Algorithm SHA512).Hash.ToLower())" >> "$env:GITHUB_OUTPUT"

finish:
runs-on: ubuntu-latest
needs: [build_unix, build_windows]
env:
YTDL_VERSION: ${{ needs.build_unix.outputs.ytdl_version }}

steps:
- name: Make SHA2-256SUMS file
env:
SHA256_BIN: ${{ needs.build_unix.outputs.sha256_bin }}
SHA256_TAR: ${{ needs.build_unix.outputs.sha256_tar }}
SHA256_WIN: ${{ needs.build_windows.outputs.sha256_win }}
run: |
echo "${{ env.SHA256_BIN }} youtube-dl" >> SHA2-256SUMS
echo "${{ env.SHA256_TAR }} youtube-dl-${YTDL_VERSION}.tar.gz" >> SHA2-256SUMS
echo "${{ env.SHA256_WIN }} youtube-dl.exe" >> SHA2-256SUMS
- name: Upload 256SUMS file
id: upload-sums
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build_unix.outputs.upload_url }}
asset_path: ./SHA2-256SUMS
asset_name: SHA2-256SUMS
asset_content_type: text/plain
- name: Make SHA2-512SUMS file
env:
SHA512_BIN: ${{ needs.build_unix.outputs.sha512_bin }}
SHA512_TAR: ${{ needs.build_unix.outputs.sha512_tar }}
SHA512_WIN: ${{ needs.build_windows.outputs.sha512_win }}
run: |
echo "${{ env.SHA512_BIN }} youtube-dl" >> SHA2-512SUMS
echo "${{ env.SHA512_TAR }} youtube-dl-${YTDL_VERSION}.tar.gz" >> SHA2-512SUMS
echo "${{ env.SHA512_WIN }} youtube-dl.exe" >> SHA2-512SUMS
- name: Upload 512SUMS file
id: upload-512sums
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build_unix.outputs.upload_url }}
asset_path: ./SHA2-512SUMS
asset_name: SHA2-512SUMS
asset_content_type: text/plain
40 changes: 40 additions & 0 deletions .github/workflows/rebase-on-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Rebase on Upstream

on:
schedule:
- cron: '53 0 * * *'
workflow_dispatch:

jobs:
rebase:
runs-on: ubuntu-latest
outputs:
build-commit: ${{ steps.relocate.outputs.build-commit }}
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Locate
shell: bash
run: |
echo "HEAD_NOW=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Rebase
uses: ytdl-org/ytdl-patched-rebase-upstream-action@master
with:
token: ${{ secrets.GH_PAT }}
upstream: ytdl-org/youtube-dl
- name: Relocate
id: relocate
shell: bash
run: |
NEW_HEAD=$(git rev-parse HEAD)
[ "${{ env.HEAD_NOW }}" = "$NEW_HEAD" ] || echo "build-commit=$NEW_HEAD" >> "$GITHUB_OUTPUT"
build:
needs: rebase
if: ${{ needs.rebase.outputs.build-commit }}
uses: ./.github/workflows/build.yml
with:
build-commit: ${{ needs.rebase.outputs.build-commit }}
33 changes: 33 additions & 0 deletions devscripts/update-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
from __future__ import unicode_literals
from datetime import datetime
import sys


with open('youtube_dl/version.py', 'rt') as f:
exec(compile(f.read(), 'youtube_dl/version.py', 'exec'))
old_version = locals()['__version__']

old_version_list = old_version.split('.')

old_ver = '.'.join(old_version_list[:3])
old_rev = old_version_list[3] if len(old_version_list) > 3 else ''

ver = datetime.utcnow().strftime("%Y.%m.%d")

rev = (sys.argv[1:] or [''])[0] # Use first argument, if present as revision number
if not rev:
rev = str(int(old_rev or 0) + 1) if old_ver == ver else ''

VERSION = '.'.join((ver, rev)) if rev else ver

VERSION_FILE = '''# Autogenerated by devscripts/update-version.py
from __future__ import unicode_literals
__version__ = {!r}
'''.format(VERSION)

with open('youtube_dl/version.py', 'wt') as f:
f.write(VERSION_FILE)

print(VERSION)
14 changes: 10 additions & 4 deletions youtube_dl/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
get_postprocessor,
)
from .version import __version__
try:
from .version import RELEASE_GIT_HEAD
except ImportError:
RELEASE_GIT_HEAD = None

if compat_os_name == 'nt':
import ctypes
Expand Down Expand Up @@ -2508,11 +2512,13 @@ def print_debug_header(self):
write_string(encoding_str, encoding=None)

writeln_debug = lambda *s: self._write_string('[debug] %s\n' % (''.join(s), ))
writeln_debug('youtube-dl version ', __version__)
writeln_debug('youtube-dl version ', __version__,
' [{0}]'.format(RELEASE_GIT_HEAD[:9]) if RELEASE_GIT_HEAD else '',
(' (single file build)' if ytdl_is_updateable() else ''))
writeln_debug('** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.')
writeln_debug('** For support, visit the main site.')
if _LAZY_LOADER:
writeln_debug('Lazy loading extractors enabled')
if ytdl_is_updateable():
writeln_debug('Single file build')
writeln_debug('[debug] Lazy loading extractors enabled')
try:
sp = subprocess.Popen(
['git', 'rev-parse', '--short', 'HEAD'],
Expand Down
Loading

0 comments on commit 9ff5511

Please sign in to comment.