Git Product home page Git Product logo

gallery-dl-view's Introduction

About

This script allows you to open a media gallery (e.g. reddit, wallpaper websites, etc.) by directly passing a gallery-dl supported url to mpv. It is inspired by the gallery-dl_hook script but has many more features such as providing commands to download media, optionally remembering and no longer displaying previously visited media files (to only see new items), etc.

By default, this script will act on urls beginning with gallery-dl:// (e.g. mpv gallery-dl://https://<rest of url>) or on urls that fail to load with any native methods (e.g. yt-dlp). For more explanation of features and options, see the settings section below.

Only one gallery per mpv instance at a time supported.

Dependencies

Installation

It is recommended to clone or download and copy this repo into the mpv scripts directory (e.g. git clone <url> ~/.config/mpv/scripts/gallery-dl-view).

Settings

In ~/.config/mpv/script-opts/gallery-dl-view.conf, you can change the following settings:

  • prefix - a file prefix to tell this script the following file/url is a gallery (default: “gallery-dl://”)
  • require_prefix - if true, only attempt to load files beginning in the prefix; if false, attempt to load any file that native methods failed to load (default: false)
  • fetch_count - the maximum number of files to add to the playlist at once; going past the last file will load the next range and going before the first file will load the previous range (default: 200)
  • gallery_url_file - a file to write the gallery url to on mpv exit; this option exists so that I can open a previously visited gallery from this file in ranger by adding configuration to the rifle.conf (default: none/don’t store)
  • visited_urls_file - a file to store visited gallery urls to (default: none/don’t store)
  • ignore_visited - whether to skip displaying previously visited files found in the visited urls file (default: false)
  • download_command - the command to run to download images (default: “gallery-dl”)
  • download_args - arguments to pass to the download command before the url (default: “-d .”, which will save in the current directory)
  • save_key - key to bind to download the current image; there is a setting for this as you may not want to have a key always bound to do this since it will only work if a gallery is open (default: none)

It is recommended to change the download command to something faster, for example to aria2c.

Here is an example configuration file:

gallery_url_file=./gallery-dl-view-url
visited_urls_file=./visited-urls
ignore_visited=yes
download_command=aria2c
# could also include --cookies <cookies file> to use with sites that require cookies
download_args=["-d", ".", "--extra-flag-1"]
save_key=x

Slowness

This method will be significantly slower than downloading an entire gallery and then opening it on disk. By default, each media file will need to be downloaded when first visiting it. Using mpv’s --prefetch-playlist flag will speed up going to the next file in the gallery (but not going backwards in the playlist).

If this is still not fast enough for you, you would be better off downloading the entire gallery (or part of it) and viewing local images instead of using this script. Any improvements to prefetching/speed should ideally be handled in mpv as this script just converts a gallery url to a bunch of natively supported urls.

Browser Integration

Using tridactyl, I have a key bound to open the current gallery url in mpv (or “mvi” which is a script I have to run mpv with a custom configuration better suited to image viewing).

bind tg composite get_current_url | shellescape | !s mvigallery

I’m using this script which creates a directory based on the gallery information (e.g. “<site name>/<gallery title>/”) and opens the gallery in mpv in that directory.

Ranger Integration

I set gallery_url_file to ./gallery so I can reopen a gallery later in ranger or Emacs. Here’s an example from my rifle.conf:

# open text file storing gallery url as gallery in mpv/mvi
file, has mvigallery, name gallery(-dl-url)?$ = tdrop -a auto_hide && mvigallery "$@" ./ && tdrop -a auto_show
# or without tdrop
file, has mvigallery, name gallery(-dl-url)?$ = mvigallery "$@" ./

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.