Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vimeo and youtube #186

Open
AlexRaycan opened this issue May 25, 2023 · 4 comments
Open

Vimeo and youtube #186

AlexRaycan opened this issue May 25, 2023 · 4 comments

Comments

@AlexRaycan
Copy link

Hi! May be storage as .txt file with link to these videos instead as strange name files? For example file media-{id}.txt and collect into it direct links to videos. and people could use this links to download them themselves or using some utils to download)

@Kratos209
Copy link

???

@vesper8
Copy link

vesper8 commented Sep 17, 2023

The links, youtube and vimeo, are all inside the embed.txt, you can make a python script to crawl over all the links and download the videos after the fact.

That's what I've done, works like a charm. Here's the script I'm using to download all the vimeo videos. For youtube it only needs minor modifications

import os
import re
import subprocess

def search_dir(directory):
    for dirpath, dirname, filenames in os.walk(directory):
        if 'embed.txt' in filenames:
            with open(os.path.join(dirpath, 'embed.txt')) as file:
                content = file.read()
                # regular expression to match vimeo URLs
                url = re.search(r'https?:\/\/(?:www\.)?vimeo\.com\/\d+\/\w+', content)
                if url:
                    download_video(url.group(), dirpath)

def download_video(url, download_dir):
    print(f'Downloading video from {url} in {download_dir}')
    try:
        output = os.path.join(download_dir, '%(title)s')
        quality = 'bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/best[height<=720][ext=mp4]'

        subprocess.run(['yt-dlp', '-o', output, '-f', quality, url])
    except Exception as e:
        print(f'Error occurred when trying to download the video: {str(e)}')


# dir=os.getcwd()
dir='/Users/xxx/Downloads/_PATREON_DOWNLOADER/xxx.collections'

search_dir(dir)

@Kratos209
Copy link

The links, youtube and vimeo, are all inside the embed.txt, you can make a python script to crawl over all the links and download the videos after the fact.

That's what I've done, works like a charm. Here's the script I'm using to download all the vimeo videos. For youtube it only needs minor modifications


import os

import re

import subprocess



def search_dir(directory):

    for dirpath, dirname, filenames in os.walk(directory):

        if 'embed.txt' in filenames:

            with open(os.path.join(dirpath, 'embed.txt')) as file:

                content = file.read()

                # regular expression to match vimeo URLs

                url = re.search(r'https?:\/\/(?:www\.)?vimeo\.com\/\d+\/\w+', content)

                if url:

                    download_video(url.group(), dirpath)



def download_video(url, download_dir):

    print(f'Downloading video from {url} in {download_dir}')

    try:

        output = os.path.join(download_dir, '%(title)s')

        quality = 'bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/best[height<=720][ext=mp4]'



        subprocess.run(['yt-dlp', '-o', output, '-f', quality, url])

    except Exception as e:

        print(f'Error occurred when trying to download the video: {str(e)}')





# dir=os.getcwd()

dir='/Users/xxx/Downloads/_PATREON_DOWNLOADER/xxx.collections'



search_dir(dir)

Where do I put this into

@vesper8
Copy link

vesper8 commented Sep 19, 2023

Doesn't matter where you put the script. Just update the path to the correct absolute path where your folders containing embed.txt are. Then run it with python. Make sure you install yt-dlp first. Should work well on Mac and Linux. On windows you'd have to modify the yt-dlp command I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants