Git Product home page Git Product logo

ximaz / lmdoit Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 47 KB

Let Me DOwnload IT is a project which lets you schemafy your download process. You'll be able to use different method for authentication, such as username:password, cookies, and so on, to use an HTML Parser, regex or just get JSON server response to download resources, and so on...

License: GNU General Public License v3.0

Python 100.00%
api api-client api-gateway api-rest download download-manager downloader http-client python requests scraper scraping scraping-python scraping-websites scrapper scrapping scrapy

lmdoit's Introduction

LMDOIT (Let Me DOwnload IT)

Let Me DOwnload IT is a project which lets you schemafy your download process.

You'll be able to use plenty of methods for :

  • authentication (cookie, username:password, bearer token, ...),
  • parsing response (HTML Parser, regex, JSON server response, ...),
  • pass custom headers to certain routes,
  • add debugging steps by downloading response into files that you can freely open,
  • add custom starting points (instead of re-doing all requests, use a downloaded file as starting point)

Example :

Here is an example about how to use the library :

import json
import pathlib
import sys
import typing

sys.path.append("../")
import lmdoit

api = lmdoit.LMDOIT()


def find_all_vidoe_mp4_export(
    youtube_video_url: str,
) -> typing.Generator[dict, typing.Any, typing.Any]:
    youtube_response = api.no_auth(url=youtube_video_url, method="GET").get_response()
    all_youtube_json_objects = youtube_response.find_json_objects_from_script_elements()

    for data in all_youtube_json_objects:
        if not isinstance(data, dict) or not "streamingData" in data.keys():
            continue
        for fmt in data["streamingData"]["adaptiveFormats"]:
            if fmt.keys() >= {"width", "height", "url"}:
                yield dict(width=fmt["width"], height=fmt["height"], url=fmt["url"])


def main():
    youtube_video_url = "https://www.youtube.com/watch?v=[THE_VIDEO_CODE]"

    pathlib.Path("youtube_formats.json").write_text(
        json.dumps(list(find_all_vidoe_mp4_export(youtube_video_url=youtube_video_url)), indent=4)
    )

if __name__ == "__main__":
    main()

Which may result in this youtube_formats.json content :

[
    {
        "width": 1920,
        "height": 1080,
        "url": "...",
    },
    {
        "width": 1920,
        "height": 1080,
        "url": "...",
    },
    {
        "width": 1280,
        "height": 720,
        "url": "...",
    },
    {
        "width": 1280,
        "height": 720,
        "url": "...",
    },
    {
        "width": 854,
        "height": 480,
        "url": "...",
    },
    {
        "width": 854,
        "height": 480,
        "url": "...",
    },
    {
        "width": 640,
        "height": 360,
        "url": "...",
    },
    {
        "width": 640,
        "height": 360,
        "url": "...",
    },
    {
        "width": 426,
        "height": 240,
        "url": "...",
    },
    {
        "width": 426,
        "height": 240,
        "url": "...",
    },
    {
        "width": 256,
        "height": 144,
        "url": "...",
    },
    {
        "width": 256,
        "height": 144,
        "url": "...",
    }
]

lmdoit's People

Contributors

ximaz avatar

Stargazers

AntoineKoiko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.