Страница 8 из 8

Добавлено: Пт, 8 сентября 2023, 14:33:31
dyvniy
https://stackoverflow.com/questions/19078969/pyth ... folder-in-a-cross-platform-way

Код: Выделить всё

import sys
import pathlib

def get_datadir
() -> pathlib.Path:

    """
    Returns a parent directory path
    where persistent application data can be stored.

    # linux: ~/.local/share
    # macOS: ~/Library/Application Support
    # windows: C:/Users/<USER>/AppData/Roaming
    """

    home = pathlib.Path.home()

    if sys.platform == "win32":
        return home / "AppData/Roaming"
    elif sys.platform == "linux":
        return home / ".local/share"
    elif sys.platform == "darwin":
        return home / "Library/Application Support"

# create your program's directory

my_datadir = get_datadir() / "program-name"

try:
    my_datadir.mkdir(parents=True)
except FileExistsError:
    pass

Добавлено: Сб, 23 сентября 2023, 22:03:03
dyvniy
Загрузка видео с YouTube с помощью Python.

python -m pip install pytube

https://github.com/pytube/pytube

Код: Выделить всё

from pytube import YouTube
YouTube('https://www.youtube.com/watch?v=513NmkH_0Q8').streams.filter(progressive=True, file_extension='mp4')[0].download()

0 - 360p
1 - 720p