Workflow TV show series for Alfred

    At the end of my previous article, I started talking about how I organized the viewing of TV shows, but decided that this was a topic for a separate note.


    For those who do not know what Alfred is

    Alfred is Spotlight on steroids. Knows a little more than everything that Spotlight can do, plus, starting with the second version, it supports writing, as well as the use of so-called workflows written by other people . That is, extensions of functionality with self-written scripts. Several scripting languages ​​are supported for writing them:


    • bash
    • zsh
    • php
    • ruby
    • python
    • perl
    • osascript
    • javascript

    This article will focus on one of these extensions.


    Looking ahead a bit, I want to show what we have in the end ...
    When it comes to relaxing and turning on the show, I launch Alfred, enter the "show" and get a list of downloaded ones in response.


    Beauty, isn't it?


    ls -R series folders
    ./
    ../
    Во все тяжкие[Кубик в Кубе]/
    Код[Alexfilm]/
    Чак[ВГТРК]/
    Мистер Робот[Lostfilm]/
    Темная материя[Lostfilm]/
    Уэйуорд Пайнс[Lostfilm]/
    Королевство[Newstudio]/
    ./Во все тяжкие[Кубик в Кубе]:
    ./
    ../
    3 сезон/
    4 сезон/
    5 сезон/
    ./Во все тяжкие[Кубик в Кубе]/3 сезон:
    ./
    ../
    Breaking.Bad.s03e04.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e05.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e06.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e07.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e08.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e09.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e10.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e11.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e12.rus.eng.Kybik.v.Kybe.avi
    Breaking.Bad.s03e13.rus.eng.Kybik.v.Kybe.avi
    ./Во все тяжкие[Кубик в Кубе]/4 сезон:
    ./
    ../
    Breaking.Bad.s04e01.k3.avi
    Breaking.Bad.s04e02.k3.avi
    Breaking.Bad.s04e03.k3.avi
    Breaking.Bad.s04e04.k3.avi
    Breaking.Bad.s04e05.k3.avi
    Breaking.Bad.s04e06.k3.avi
    Breaking.Bad.s04e07.k3.avi
    Breaking.Bad.s04e08.k3.avi
    Breaking.Bad.s04e09.k3.avi
    Breaking.Bad.s04e10.k3.avi
    Breaking.Bad.s04e11.k3.avi
    Breaking.Bad.s04e12.k3.avi
    Breaking.Bad.s04e13.k3.avi
    ./Во все тяжкие[Кубик в Кубе]/5 сезон:
    ./
    ../
    Vo.vse.tyazkie.(5.sezon.01.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.02.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.03.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.04.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.05.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.06.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.07.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.08.seriya.iz.16).2012.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.09.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.10.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.11.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.12.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.13.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.14.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.15.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    Vo.vse.tyazkie.(5.sezon.16.seriya.iz.16).2013.x264.WEB-DL.720p.Kubik.v.Kube.mkv
    ./Код[Alexfilm]:
    ./
    ../
    The.Code.E03.WEB-DLRip.Rus.Eng.AlexFilm.avi
    The.Code.E04.WEB-DLRip.Rus.Eng.AlexFilm.avi
    The.Code.E05.WEB-DLRip.Rus.Eng.AlexFilm.avi
    The.Code.E06.WEB-DLRip.Rus.Eng.AlexFilm.avi
    ./Чак[ВГТРК]:
    ./
    ../
    3 сезон/
    4 сезон/
    ./Чак[ВГТРК]/3 сезон:
    ./
    ../
    Chuck.s03e01.HDRip.avi
    Chuck.s03e02.HDRip.avi
    Chuck.s03e03.HDRip.avi
    Chuck.s03e04.HDRip.avi
    Chuck.s03e05.HDRip.avi
    Chuck.s03e06.HDRip.avi
    Chuck.s03e07.HDRip.avi
    Chuck.s03e08.HDRip.avi
    Chuck.s03e09.HDRip.avi
    Chuck.s03e10.HDRip.avi
    Chuck.s03e11.HDRip.avi
    Chuck.s03e12.HDRip.avi
    Chuck.s03e13.HDRip.avi
    Chuck.s03e14.HDRip.avi
    Chuck.s03e15.HDRip.avi
    Chuck.s03e16.HDRip.avi
    Chuck.s03e17.HDRip.avi
    Chuck.s03e18.HDRip.avi
    Chuck.s03e19.HDRip.avi
    ./Чак[ВГТРК]/4 сезон:
    ./
    ../
    Chuck.s04e01.HDRip.avi
    Chuck.s04e02.HDRip.avi
    Chuck.s04e03.HDRip.avi
    Chuck.s04e04.HDRip.avi
    Chuck.s04e05.HDRip.avi
    Chuck.s04e06.HDRip.avi
    Chuck.s04e07.HDRip.avi
    Chuck.s04e08.HDRip.avi
    Chuck.s04e09.HDRip.avi
    Chuck.s04e10.HDRip.avi
    Chuck.s04e11.HDRip.avi
    Chuck.s04e12.HDRip.avi
    Chuck.s04e13.HDRip.avi
    Chuck.s04e14.HDRip.avi
    Chuck.s04e15.HDRip.avi
    Chuck.s04e16.HDRip.avi
    Chuck.s04e17.HDRip.avi
    Chuck.s04e18.HDRip.avi
    Chuck.s04e19.HDRip.avi
    Chuck.s04e20.HDRip.avi
    Chuck.s04e21.HDRip.avi
    Chuck.s04e22.HDRip.avi
    Chuck.s04e23.HDRip.avi
    Chuck.s04e24.HDRip.avi
    ./Мистер Робот[Lostfilm]:
    ./
    ../
    Mr.Robot.S02E03.1080p.rus.LostFilm.TV.mkv
    ./Темная материя[Lostfilm]:
    ./
    ../
    Dark.Matter.S02E04.720p.WEB.rus.LostFilm.TV.mp4
    ./Уэйуорд Пайнс[Lostfilm]:
    ./
    ../
    Wayward.Pines.S02E09.1080p.rus.LostFilm.TV.mkv
    ./Королевство[Newstudio]:
    ./
    ../
    Kingdom.s02e17.HDTV.720p.NewStudio.TV.mkv

    That is, the title and subtitle are taken from the directory names. For example, the last line from the list above is the folder "Chuck [VGTRK]" with subfolders of the seasons. If the folder name does not contain square brackets, its element in the Alfred list will not have a subtitle.


    When we select the item of interest, the player starts (in my case - VLC ) and starts playing the first unviewed series from the selected section. At the end of playback, it closes on its own (VLC has the --play-and-exit option). After which the script suggests deleting the watched episode, asks how much you liked it on a five-point scale and marks it watched with the appropriate rating on myshows.me . Notifies of success / failure. And, if the notification says that everything is fine, by clicking on it you can get directly to the page of the episode you just watched. Since version 1.5 , workflow does not require the myshows.me account to function properly (implying corresponding functionality limitations).


    For notifications, a terminal-notifier is used , which is included in the workflow.
    Also dependencies are requests and alfred-workflow packages for python. Both are also included in the workflow.


    Before use, workflow will prompt you to specify:


    • The folder in which the series are located
    • A player that will play them
    • Login and password with myshows.me (from version 1.5 - optional)

    Bonuses


    The following only works if you specify credentials with myshows.me


    In addition to watching TV shows, I made it possible to see a list of already released, but not yet viewed, data from the account on myshows.me.


    Unwatched


    And also, a list of those that will be released relatively soon. Again using api myshows.me and a list of subscriptions.


    Mr.  Robot


    TBBT


    Entering the name of the series after the keyword, you can filter the output, and if you select an item in any of them, the page of the corresponding episode opens.


    Link to workflow .
    Implemented auto-update using GitHub Releases.


    Also popular now: