<commit_before># Flexget (http://www.flexget.com) configuration file.
#
# originally Created by: <NAME> <<EMAIL>>
# His work is available from: https://github.com/jawilson/dotfiles/tree/master/flexget
#
# This fork was created by: <NAME> <<EMAIL>>
# Available at: https://github.com/sisfs/dotfiles/tree/adding-my-changes
#
# Many Changes have been made from Jeff's work. Still, if it werent for his vision I would have had no idea where to start.
#
# All of my media is stored on a NAS4Free server with Plex Media Server and Deluge/Flexget running in separate Jails. 
# User plex and user deluge both share the same uid which fixes a ton of permission problems that I originally had.


# Use the secrets plugin to separately store credentials, etc... want to find out whether or not i can store directories in secretfile.
# I need to figure out whether or not you can daisy chain secrets files... if so one config can service many users without shared passwords =)
secrets: secretfile.yml

# this web config is here for when it becomes a usable feature
web_server:
  bind: 0.0.0.0
  port: 5050
api: yes
webui: yes


templates:
  # eventually all this torrentleech talk will come in handy.
  global:
    if:
      - "'torrentleech' in url":
          deluge:
            username: '{{ secrets.deluge.username }}'
            password: '{{ <PASSWORD> }}'
            main_file_only: yes # Ignore all but the file that is >90% of the torrent if it exists
            keep_subs: no
            port: 58846 # changed from 58845 as things broke otherwise
      - "'torrentleech' not in url":
          deluge:
            username: '{{ secrets.deluge.username }}'
            password: '{{ <PASSWORD> }}'
            main_file_only: yes # Ignore all but the file that is >90% of the torrent if it exists
            keep_subs: no
            port: 58846
    # Make sure there's 50GB free before adding more downloads
    free_space: 
      path: '{{ secrets.directories.rootmediadir }}'
      space: 50000
    # Make sure all filenames are Windows safe (for samba)
    pathscrub: windows
    # Jeff: Most of these are the results of problem torrents I kept seeing still pop up, so I wholesale blocked them
    # RegExr (http://www.gskinner.com/RegExr/) is a great tool for testing regexes
    regexp:
      reject:
        - (s|d)ub(s|bed)?\b: {from: title}                    # Block any subbed/dubbed/etc videos
        - \bspanish\b: {from: title}                          # Spanish releases kept cropping up
        - \b(duo|tri|quadri|tetra|penta)logy\b: {from: title} # Block series, only accept one at a time
        - \b3-?D\b: {from: title}                             # I don't have any 3D displays
        - \btrailer\b: {from: title}                          # I've gotten a few trailers that matched as movies. VERY annoying
        - \bR5\b: {from: title}                               # The following are poor quality types that somehow got through the quality
        - \bWEBSCR\b: {from: title}                           # features usually due to the title including a keyword like "720p" as well
        - \bscreener\b: {from: title}
        - \bTS\b: {from: title}
        - \bCam\b: {from: title}
        - '{C_P}': {from: title}                              # The following are groups with poor quality releases
        - TrTd TeaM: {from: title}
        - \[TNTVillage\]: {from: title}
        - \[facepalm\]: {from: title}
        - \bASAP\b: {from: title}
        - the.day.of.the.doctor                               # The following are titles that caused me issues from plugins
    # Require at least 5 seeds of any torrent
    torrent_alive:
      min_seeds: 5
      reject_for: 1 day
    # Filter by filenames. Allow multiple video types and rar packs (but note if there is just a
    # single .rar file it won't be accepted)
    content_filter:
      require:
        - '*.avi'
        - '*.mkv'
        - '*.mpg'
        - '*.mp4'
        - '*.r0*'
        - '*.part0*'
      reject:
        - 'password.txt'
        - '*.wmv'
    # Limit the frequency of requests to domains so they don't complain about
    # using a bot
    domain_delay:
      www.torrentleech.org: 10 seconds
      rss.torrentleech.org: 10 minutes
      bt-chat.com: 5 seconds
      torrentz.eu: 10 seconds
    # The Pirate Bay ssl certs always fail
    verify_ssl_certificates: no
    # Size and seed restrictions require real torrents
    magnets: no

  # Jeff: This template is a "global" template for all TV-related tasks.
  # We keep all of the RSS feeds that list tv-related torrents here
  # as well as where to check existing shows.
  tv-global:
    inputs:
      # - rss: { url: 'http://rss.torrentleech.org/{{ secrets.torrentleech.rss_key }}', other_fields: [category] }
      #- rss: { url: 'http://www.torlock.com/television/rss.xml', silent: yes }                    # TorLock (TV)
      #- rss: { url: 'http://torrentz.eu/feed_verified?q=tv', silent: yes }                        # Torrentz (Verified only, TV)
      - rss: { url: 'https://kat.cr/usearch/verified%3A1%20category%3Atv/?rss=1', silent: yes }   # Kickass (TV)
    if:
      - "has_field('category')":
          regexp:
            reject_excluding:
              - '^Episodes( HD)?$': {from: category}
    archive: [tv]
    # Impose reasonable size constraints
    content_size:
      max: 2000
      min: 128
    # Prevent from downloading shows that were aquired manually
    # or are currently downloading
    exists_series: # change from UNC paths when i move deluge and flexget to the server. ##
      - '{{ secrets.directories.tvshow_dir }}'
      - '{{ secrets.directories.incomplete_dir }}'
      - '{{ secrets.directories.download_dir }}'
      - '{{ secrets.directories.completed_dir }}'
    thexem:
      source: scene
      destination: tvdb
    # Look up info on TheTVDB.com to fill in extra info
    thetvdb_lookup: yes
    require_field: [series_name, series_id]
    pushbullet: # I absolutely love the idea of using Pushbullet to notify; this definitely came from Jeff.
      apikey: '{{ secrets.pushbullet.apikey }}'
      title: "[Flexget] {{task}}"
      body: "{{ tvdb_series_name|default(series_name) }} - {{ series_id }}{% if tvdb_ep_name|default(False) %} - {{ tvdb_ep_name }}{% endif %}\n{{ quality }}"
      url: "{% if trakt_series_url is defined and trakt_season is defined and trakt_episode is defined %}{{ trakt_series_url }}/season/{{ trakt_season }}/episode/{{ trakt_episode }}{% endif %}"
    # Add accepted entries to Deluge and make sure they end up in the correct
    # folder with a nice name
    set: # had to change a ton in this area. I wanted dots instead of spaces; wanted 2 digit season numbers on folders. I still need to figure out how to remove Apostrophes reliably.
      queuetotop: yes
      movedone: >
        '{{ secrets.directories.tvshow_dir }}'{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}/{% if series_id_type == 'ep' %}Season.{{ series_season|pad(2) }}/{% endif %}
      # Rename the "content file" to something nice, use leading slash to force file to top level
      content_filename: >
        /{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}-{{ series_id }}{% if tvdb_ep_name|default(False) %}-{{ tvdb_ep_name|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}{% endif %}-{{ quality|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}
      label: tv
    # Jeff: This is a custom plugin, it is part of my rar-unpacking method,
    # it changes 'movedone' based on the regexp in the key
    content_sort:
      '*.rar': '{{ secrets.directories.stagingtv_dir }}' ##


  tv-shows-find:
    discover:
      what: [filler: yes]
      from:
        #- torrentleech: # see note below
        #    rss_key: '{{ secrets.torrentleech.rss_key }}'
        #    username: '{{ secrets.torrentleech.username }}'
        #    password: '{{ <PASSWORD> }}'
        #    category: ['Episodes HD', 'Episodes']
        - flexget_archive: [tv]
        - torrentz: verified
        - kat:
            category: tv
            verified: yes

  # Jeff: This template is a "global" template for all movie-related tasks.
  # We keep all of the RSS feeds that list movie-related torrents here
  # as well as some other configurations.
  movies-global:
    inputs:
    #  - rss: { url: 'http://rss.torrentleech.org/{{ secrets.torrentleech.rss_key }}', other_fields: [category] }
      - rss: { url: 'http://www.torlock.com/movies/rss.xml', silent: yes }     # TorLock (Movies)
      - rss: { url: 'http://torrentz.eu/feed_verified?q=movies', silent: yes } # Torrentz (Verified Movies)
      - rss: 'https://kat.cr/usearch/verified%3A1%20category%3Amovies/?rss=1' # Kickass (Movies)
    # Some feeds might include TV Shows, ignore them
    if:
      - "has_field('category')":
          regexp:
            reject_excluding:
              - '^(HD|BDRip|DVDRip.DVDScreener|DVD-R|Documentaries)$': {from: category}
    archive: [movies]
    regexp:
      reject:
        - s\d+e\d+: {from: title}
        - '\d{4}.\d{2}.\d{2}': {from: title}
        - \d+x\d+: {from: title}
        - \baac2: {from: title} # No 2 channel audio
    # Force proper_movies to run after regexp to avoid unnecessary imdb_lookup
    plugin_priority:
      regexp: 176
      if: 177
      proper_movies: 171
    # Impose reasonable size constraints
    content_size:
      max: 4000
      min: 300
    imdb_lookup: yes
    # Check for already downloaded or currently downloading movies
    exists_movie: 
      - '{{ secrets.directories.movies_dir }}'
      - '{{ secrets.directories.stagingmovies_dir }}'
      - '{{ secrets.directories.checkdir }}'
    # Download propers, since they will have the same content_filename,
    # lower/non-propers will be overwritten
    proper_movies: yes
    set: 
      # Give folders/files nice names ##
      movedone: "{{ secrets.directories.movies_dir }}{{ imdb_name|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}.{{ imdb_year }}"
      # Rename the "content file" to something nice, use leading slash to force file to top level ##
      content_filename: |
        /{{ imdb_name|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}-{{ imdb_year }}-{{ quality|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}
    pushbullet:
      apikey: '{{ secrets.pushbullet.apikey }}'
      title: "[Flexget] {{task}}"
      body: "{{ imdb_name }} ({{ imdb_year }})\n{{ quality }}"
      url: "{% if imdb_url %}{{ imdb_url }}{% endif %}"
    # Jeff: This is a custom plugin, it is part of my rar-unpacking method, it changes
    # 'movedone' based on the regexp in the key
    content_sort:
      '*.rar': '{{ secrets.directories.movies_dir }}'
      

  # Keep all the discover settings in one place
  movies-discover:
    discover:
      from:
        #- torrentleech: # I dont yet have an account but, i will test if i get an invite
        #    rss_key: '{{ secrets.torrentleech.rss_key }}'
        #    username: '{{ secrets.torrentleech.username }}'
        #    password: '{{ <PASSWORD> }}'
        #    category: ['HD', 'BDRip', 'DVDRip', 'DVDR', 'Documentaries']
        - flexget_archive: [movies]
        - torrentz:
            reputation: verified
            extra_terms: "movie* hd"
        - kat:
            category: movies
            verified: yes
      what: [ filler: yes ] # Always produce entries


  # Jeff: This template runs feeds through my very specific custom filter
  movies-auto: # not sure if this is even available on my system.
    my_movie_filter: yes
    set:
      queuetotop: no
      label: movies-auto


  # This template uses the movie queue to find movies from various sources
  movies-queued:
    movie_queue: accept
    template: movies-discover
    disable:
      - seen_movies
    discover:
      what:
        - emit_movie_queue: yes
      from: [ filler: yes ] # Always produce entries
    trakt_remove: # Remove from Trakt list when we accept an item
      account: '{{ secrets.trakt.username }}'
      list: '{{ secrets.trakt.remove_list }}'
    trakt_add: # Add accepted item to my Trakt watchlist
      account: '{{ secrets.trakt.username }}'
      list: '{{ secrets.trakt.add_list }}'
    set:
      label: my-movies


# This is where we pull everything together
tasks:
  Sync-TV-Shows:
    manual: yes
    template: no_global # None of the global templates make sense here
    filesystem:
      path: ##
        - '{{ secrets.directories.series_dir }}'
      regexp: '.*\.(avi|mkv|mp4|mpg|m4v)$'
      recursive: yes
    regexp:
      reject:
        - \bsample\b: {from: title}
    disable: builtins
    thexem:
      source: tvdb
      destination: scene
    sequence:
      - configure_series:
          settings:
            tracking: no
            identified_by: ep
          from:
            trakt_list:
              account: '{{ secrets.trakt.username }}'
              list: '{{ secrets.trakt.follow_list }}'
              type: shows
              strip_dates: yes 
    exec: echo "Found {{ series_name }} - {{ series_id }} ({{ location }})" >> /dev/null


  # All of the TV-related tasks pull in the tv-global template, this gives
  # all of the necessary rss sources and a few extra configs

  # There are 3 My-TV Shows tasks, the first, tries to get the most wanted qualities
  My-TV-Shows:
    priority: 10
    template: [tv-global]
    sequence:
      - configure_series:
          settings:
            target: 720p+ dvdscr+
            timeframe: 3 days
            quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## testing to see why all my shows are failing
            tracking: backfill
            identified_by: ep
          from:
            trakt_list:
              account: '{{ secrets.trakt.username }}'
              list: '{{ secrets.trakt.follow_list }}' #was 'Following TV' without quotes
              type: shows
              strip_dates: yes


  My-TV-Shows-Find-Next-Following:
    template: [tv-global, tv-shows-find]
    disable: inputs
    discover:
      interval: 2 hours
      what:
        - trakt_emit:
            account: '{{ secrets.trakt.username }}'
            list: '{{ secrets.trakt.follow_list }}'
            context: collected
            position: next
      from: [filler: yes]
    all_series:
      target: 720p+ dvdscr+
      timeframe: 3 days
      quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## testing to see why all my shows are failing
      tracking: backfill


  My-TV-Shows-Find-Missing:
    template:
      - tv-global
      - tv-shows-find
    disable: inputs, est_movies
    discover:
      what:
        - emit_series:
            backfill: yes
      from: [filler: yes]
    sequence:
      - configure_series:
          settings:
            target: 720p+ dvdscr+
            timeframe: 3 days
            quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## testing to see why all my shows are failing 
            tracking: backfill
            propers: no
            upgrade: no
            identified_by: ep
          from:
            trakt_list:
              account: '{{ secrets.trakt.username }}'
              list: '{{ secrets.trakt.follow_list }}'
              type: shows
              strip_dates: yes


  # manual task to freshen up the series begin dates for download run with:
  # flexget execute --tasks my-tv-shows-set-begin
  my-tv-shows-set-begin:          
    manual: yes
    template: no_global
    trakt_emit:
      account: '{{ secrets.trakt.username }}'
      list: '{{ secrets.trakt.follow_list }}'
      context: collected  # You can set this to 'watched' depending on the state of your trakt info
      position: next
    accept_all: yes
    set_series_begin: yes
              
  # Jeff: I'm always up for new shows, but some I genres I just can't stand. This
  # task grabs all of the premieres except for some genres
  Series-Premieres:
    priority: 40
    template:
      - tv-global
    # The entry has to have the tvdb_genres field so I can filter by it
    require_field:
      - tvdb_genres
      - tvdb_first_air_date
    # Make sure plenty of people are seeding it, otherwise it may not be that good
    torrent_alive:
      min_seeds: 30
    # Block these genres if they exist in the list of tvdb_genres at all
    regexp:
      reject:
        - documentary: {from: tvdb_genres}
        - talk show: {from: tvdb_genres}
        - game show: {from: tvdb_genres}
        - reality: {from: tvdb_genres}
        # - crime: {from: tvdb_genres}
        # - children: {from: tvdb_genres}
        # - home and garden: {from: tvdb_genres}
    if:
      # Block these genres only if they are the ONLY genre listed in
      # tvdb_genres. For example, this will not block a show that's both
      # "Comedy" and "Drama" but it will block a show that is just "Drama"
      - "tvdb_genres == ['Drama']": reject
      # Block premieres that weren't within the last 60 days
      - tvdb_first_air_date and tvdb_first_air_date < now - timedelta(days=60): reject
    # Accept all series permieres
    series_premiere:
      timeframe: 1 days
      quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## maybe i'll get more premiere results now
    # Add to deluge, but don't queue to top (My_TV_Shows are more important)
    # and put in a different location
    set: 
      movedone: >
        {{ secrets.trakt.premieres_dir }}{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}/{% if series_id_type == 'ep' %}Season {{ series_season|pad(2) }}/{% endif %}
      queuetotop: no
      label: tv-premiere
    # This is a custom plugin, it is part of my rar-unpacking method, it changes
    # 'movedone' based on the regexp in the key
    content_sort: ##
      '*.rar': '{{ secrets.trakt.checkdir }'

  
  # If a premier was grabbed, keep on tracking it until the directory is (re)moved
  Series-Premieres-Track:
    priority: 50
    template:
      - tv-global
    configure_series:
      settings:
        target: 720p+ hdtv+
        timeframe: 3 days
        quality: 720p|480p|1080p h264 ac3|aac|mp3
        identified_by: ep
      from:
        filesystem: ##
          - {{ secrets.trakt.premieres_dir }}
    set: # see above
      movedone: >
        {{ secrets.trakt.premieres_dir }}{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}/{% if series_id_type == 'ep' %}Season.{{ series_season|pad(2) }}/{% endif %}
      queuetotop: no
      label: tv-premiere-track
    content_sort: ##<commit_msg>Update config.yml<commit_after># Flexget (http://www.flexget.com) configuration file.
#
# originally Created by: <NAME> <<EMAIL>>
# His work is available from: https://github.com/jawilson/dotfiles/tree/master/flexget
#
# This fork was created by: <NAME> <<EMAIL>>
# Available at: https://github.com/sisfs/dotfiles/tree/adding-my-changes
#
# Many Changes have been made from Jeff's work. Still, if it werent for his vision I would have had no idea where to start.
#
# All of my media is stored on a NAS4Free server with Plex Media Server and Deluge/Flexget running in separate Jails. 
# User plex and user deluge both share the same uid which fixes a ton of permission problems that I originally had.


# Use the secrets plugin to separately store credentials, etc... want to find out whether or not i can store directories in secretfile.
# I need to figure out whether or not you can daisy chain secrets files... if so one config can service many users without shared passwords =)
secrets: secretfile.yml

# this web config is here for when it becomes a usable feature
web_server:
  bind: 0.0.0.0
  port: 5050
api: yes
webui: yes


templates:
  # eventually all this torrentleech talk will come in handy.
  global:
    if:
      - "'torrentleech' in url":
          deluge:
            username: '{{ secrets.deluge.username }}'
            password: '{{ <PASSWORD> }}'
            main_file_only: yes # Ignore all but the file that is >90% of the torrent if it exists
            keep_subs: no
            port: 58846 # changed from 58845 as things broke otherwise
      - "'torrentleech' not in url":
          deluge:
            username: '{{ secrets.deluge.username }}'
            password: '{{ <PASSWORD> }}'
            main_file_only: yes # Ignore all but the file that is >90% of the torrent if it exists
            keep_subs: no
            port: 58846
    # Make sure there's 50GB free before adding more downloads
    free_space: 
      path: '{{ secrets.directories.rootmediadir }}'
      space: 50000
    # Make sure all filenames are Windows safe (for samba)
    pathscrub: windows
    # Jeff: Most of these are the results of problem torrents I kept seeing still pop up, so I wholesale blocked them
    # RegExr (http://www.gskinner.com/RegExr/) is a great tool for testing regexes
    regexp:
      reject:
        - (s|d)ub(s|bed)?\b: {from: title}                    # Block any subbed/dubbed/etc videos
        - \bspanish\b: {from: title}                          # Spanish releases kept cropping up
        - \b(duo|tri|quadri|tetra|penta)logy\b: {from: title} # Block series, only accept one at a time
        - \b3-?D\b: {from: title}                             # I don't have any 3D displays
        - \btrailer\b: {from: title}                          # I've gotten a few trailers that matched as movies. VERY annoying
        - \bR5\b: {from: title}                               # The following are poor quality types that somehow got through the quality
        - \bWEBSCR\b: {from: title}                           # features usually due to the title including a keyword like "720p" as well
        - \bscreener\b: {from: title}
        - \bTS\b: {from: title}
        - \bCam\b: {from: title}
        - '{C_P}': {from: title}                              # The following are groups with poor quality releases
        - TrTd TeaM: {from: title}
        - \[TNTVillage\]: {from: title}
        - \[facepalm\]: {from: title}
        - \bASAP\b: {from: title}
        - the.day.of.the.doctor                               # The following are titles that caused me issues from plugins
    # Require at least 5 seeds of any torrent
    torrent_alive:
      min_seeds: 5
      reject_for: 1 day
    # Filter by filenames. Allow multiple video types and rar packs (but note if there is just a
    # single .rar file it won't be accepted)
    content_filter:
      require:
        - '*.avi'
        - '*.mkv'
        - '*.mpg'
        - '*.mp4'
        - '*.r0*'
        - '*.part0*'
      reject:
        - 'password.txt'
        - '*.wmv'
    # Limit the frequency of requests to domains so they don't complain about
    # using a bot
    domain_delay:
      www.torrentleech.org: 10 seconds
      rss.torrentleech.org: 10 minutes
      bt-chat.com: 5 seconds
      torrentz.eu: 10 seconds
    # The Pirate Bay ssl certs always fail
    verify_ssl_certificates: no
    # Size and seed restrictions require real torrents
    magnets: no

  # Jeff: This template is a "global" template for all TV-related tasks.
  # We keep all of the RSS feeds that list tv-related torrents here
  # as well as where to check existing shows.
  tv-global:
    inputs:
      # - rss: { url: 'http://rss.torrentleech.org/{{ secrets.torrentleech.rss_key }}', other_fields: [category] }
      #- rss: { url: 'http://www.torlock.com/television/rss.xml', silent: yes }                    # TorLock (TV)
      #- rss: { url: 'http://torrentz.eu/feed_verified?q=tv', silent: yes }                        # Torrentz (Verified only, TV)
      - rss: { url: 'https://kat.cr/usearch/verified%3A1%20category%3Atv/?rss=1', silent: yes }   # Kickass (TV)
    if:
      - "has_field('category')":
          regexp:
            reject_excluding:
              - '^Episodes( HD)?$': {from: category}
    archive: [tv]
    # Impose reasonable size constraints
    content_size:
      max: 2000
      min: 128
    # Prevent from downloading shows that were aquired manually
    # or are currently downloading
    exists_series: # change from UNC paths when i move deluge and flexget to the server. ##
      - '{{ secrets.directories.tvshow_dir }}'
      - '{{ secrets.directories.incomplete_dir }}'
      - '{{ secrets.directories.download_dir }}'
      - '{{ secrets.directories.completed_dir }}'
    thexem:
      source: scene
      destination: tvdb
    # Look up info on TheTVDB.com to fill in extra info
    thetvdb_lookup: yes
    require_field: [series_name, series_id]
    pushbullet: # I absolutely love the idea of using Pushbullet to notify; this definitely came from Jeff.
      apikey: '{{ secrets.pushbullet.apikey }}'
      title: "[Flexget] {{task}}"
      body: "{{ tvdb_series_name|default(series_name) }} - {{ series_id }}{% if tvdb_ep_name|default(False) %} - {{ tvdb_ep_name }}{% endif %}\n{{ quality }}"
      url: "{% if trakt_series_url is defined and trakt_season is defined and trakt_episode is defined %}{{ trakt_series_url }}/season/{{ trakt_season }}/episode/{{ trakt_episode }}{% endif %}"
    # Add accepted entries to Deluge and make sure they end up in the correct
    # folder with a nice name
    set: # had to change a ton in this area. I wanted dots instead of spaces; wanted 2 digit season numbers on folders. I still need to figure out how to remove Apostrophes reliably.
      queuetotop: yes
      movedone: >
        '{{ secrets.directories.tvshow_dir }}'{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}/{% if series_id_type == 'ep' %}Season.{{ series_season|pad(2) }}/{% endif %}
      # Rename the "content file" to something nice, use leading slash to force file to top level
      content_filename: >
        /{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}-{{ series_id }}{% if tvdb_ep_name|default(False) %}-{{ tvdb_ep_name|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}{% endif %}-{{ quality|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}
      label: tv
    # Jeff: This is a custom plugin, it is part of my rar-unpacking method,
    # it changes 'movedone' based on the regexp in the key
    content_sort:
      '*.rar': '{{ secrets.directories.stagingtv_dir }}' ##


  tv-shows-find:
    discover:
      what: [filler: yes]
      from:
        #- torrentleech: # see note below
        #    rss_key: '{{ secrets.torrentleech.rss_key }}'
        #    username: '{{ secrets.torrentleech.username }}'
        #    password: '{{ <PASSWORD> }}'
        #    category: ['Episodes HD', 'Episodes']
        - flexget_archive: [tv]
        - torrentz: verified
        - kat:
            category: tv
            verified: yes

  # Jeff: This template is a "global" template for all movie-related tasks.
  # We keep all of the RSS feeds that list movie-related torrents here
  # as well as some other configurations.
  movies-global:
    inputs:
    #  - rss: { url: 'http://rss.torrentleech.org/{{ secrets.torrentleech.rss_key }}', other_fields: [category] }
      - rss: { url: 'http://www.torlock.com/movies/rss.xml', silent: yes }     # TorLock (Movies)
      - rss: { url: 'http://torrentz.eu/feed_verified?q=movies', silent: yes } # Torrentz (Verified Movies)
      - rss: 'https://kat.cr/usearch/verified%3A1%20category%3Amovies/?rss=1' # Kickass (Movies)
    # Some feeds might include TV Shows, ignore them
    if:
      - "has_field('category')":
          regexp:
            reject_excluding:
              - '^(HD|BDRip|DVDRip.DVDScreener|DVD-R|Documentaries)$': {from: category}
    archive: [movies]
    regexp:
      reject:
        - s\d+e\d+: {from: title}
        - '\d{4}.\d{2}.\d{2}': {from: title}
        - \d+x\d+: {from: title}
        - \baac2: {from: title} # No 2 channel audio
    # Force proper_movies to run after regexp to avoid unnecessary imdb_lookup
    plugin_priority:
      regexp: 176
      if: 177
      proper_movies: 171
    # Impose reasonable size constraints
    content_size:
      max: 4000
      min: 300
    imdb_lookup: yes
    # Check for already downloaded or currently downloading movies
    exists_movie: 
      - '{{ secrets.directories.movies_dir }}'
      - '{{ secrets.directories.stagingmovies_dir }}'
      - '{{ secrets.directories.checkdir }}'
    # Download propers, since they will have the same content_filename,
    # lower/non-propers will be overwritten
    proper_movies: yes
    set: 
      # Give folders/files nice names ##
      movedone: "{{ secrets.directories.movies_dir }}{{ imdb_name|replace('/', '_')|replace(': ', '-')|replace(':', '-')|replace(',', '')|replace(' ', '.') }}.{{ imdb_year }}"
      # Rename the "content file" to something nice, use leading slash to force file to top level ##
      content_filename: |
        /{{ imdb_name|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}-{{ imdb_year }}-{{ quality|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}
    pushbullet:
      apikey: '{{ secrets.pushbullet.apikey }}'
      title: "[Flexget] {{task}}"
      body: "{{ imdb_name }} ({{ imdb_year }})\n{{ quality }}"
      url: "{% if imdb_url %}{{ imdb_url }}{% endif %}"
    # Jeff: This is a custom plugin, it is part of my rar-unpacking method, it changes
    # 'movedone' based on the regexp in the key
    content_sort:
      '*.rar': '{{ secrets.directories.movies_dir }}'
      

  # Keep all the discover settings in one place
  movies-discover:
    discover:
      from:
        #- torrentleech: # I dont yet have an account but, i will test if i get an invite
        #    rss_key: '{{ secrets.torrentleech.rss_key }}'
        #    username: '{{ secrets.torrentleech.username }}'
        #    password: '{{ <PASSWORD> }}'
        #    category: ['HD', 'BDRip', 'DVDRip', 'DVDR', 'Documentaries']
        - flexget_archive: [movies]
        - torrentz:
            reputation: verified
            extra_terms: "movie* hd"
        - kat:
            category: movies
            verified: yes
      what: [ filler: yes ] # Always produce entries


  # Jeff: This template runs feeds through my very specific custom filter
  movies-auto: # not sure if this is even available on my system.
    my_movie_filter: yes
    set:
      queuetotop: no
      label: movies-auto


  # This template uses the movie queue to find movies from various sources
  movies-queued:
    movie_queue: accept
    template: movies-discover
    disable:
      - seen_movies
    discover:
      what:
        - emit_movie_queue: yes
      from: [ filler: yes ] # Always produce entries
    trakt_remove: # Remove from Trakt list when we accept an item
      account: '{{ secrets.trakt.username }}'
      list: '{{ secrets.trakt.remove_list }}'
    trakt_add: # Add accepted item to my Trakt watchlist
      account: '{{ secrets.trakt.username }}'
      list: '{{ secrets.trakt.add_list }}'
    set:
      label: my-movies


# This is where we pull everything together
tasks:
  Sync-TV-Shows:
    manual: yes
    template: no_global # None of the global templates make sense here
    filesystem:
      path: ##
        - '{{ secrets.directories.series_dir }}'
      regexp: '.*\.(avi|mkv|mp4|mpg|m4v)$'
      recursive: yes
    regexp:
      reject:
        - \bsample\b: {from: title}
    disable: builtins
    thexem:
      source: tvdb
      destination: scene
    sequence:
      - configure_series:
          settings:
            tracking: no
            identified_by: ep
          from:
            trakt_list:
              account: '{{ secrets.trakt.username }}'
              list: '{{ secrets.trakt.follow_list }}'
              type: shows
              strip_dates: yes 
    exec: echo "Found {{ series_name }} - {{ series_id }} ({{ location }})" >> /dev/null


  # All of the TV-related tasks pull in the tv-global template, this gives
  # all of the necessary rss sources and a few extra configs

  # There are 3 My-TV Shows tasks, the first, tries to get the most wanted qualities
  My-TV-Shows:
    priority: 10
    template: [tv-global]
    sequence:
      - configure_series:
          settings:
            target: 720p+ dvdscr+
            timeframe: 3 days
            quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## testing to see why all my shows are failing
            tracking: backfill
            identified_by: ep
          from:
            trakt_list:
              account: '{{ secrets.trakt.username }}'
              list: '{{ secrets.trakt.follow_list }}' #was 'Following TV' without quotes
              type: shows
              strip_dates: yes


  My-TV-Shows-Find-Next-Following:
    template: [tv-global, tv-shows-find]
    disable: inputs
    discover:
      interval: 2 hours
      what:
        - trakt_emit:
            account: '{{ secrets.trakt.username }}'
            list: '{{ secrets.trakt.follow_list }}'
            context: collected
            position: next
      from: [filler: yes]
    all_series:
      target: 720p+ dvdscr+
      timeframe: 3 days
      quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## testing to see why all my shows are failing
      tracking: backfill


  My-TV-Shows-Find-Missing:
    template:
      - tv-global
      - tv-shows-find
    disable: inputs, est_movies
    discover:
      what:
        - emit_series:
            backfill: yes
      from: [filler: yes]
    sequence:
      - configure_series:
          settings:
            target: 720p+ dvdscr+
            timeframe: 3 days
            quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## testing to see why all my shows are failing 
            tracking: backfill
            propers: no
            upgrade: no
            identified_by: ep
          from:
            trakt_list:
              account: '{{ secrets.trakt.username }}'
              list: '{{ secrets.trakt.follow_list }}'
              type: shows
              strip_dates: yes


  # manual task to freshen up the series begin dates for download run with:
  # flexget execute --tasks my-tv-shows-set-begin
  my-tv-shows-set-begin:          
    manual: yes
    template: no_global
    trakt_emit:
      account: '{{ secrets.trakt.username }}'
      list: '{{ secrets.trakt.follow_list }}'
      context: collected  # You can set this to 'watched' depending on the state of your trakt info
      position: next
    accept_all: yes
    set_series_begin: yes
              
  # Jeff: I'm always up for new shows, but some I genres I just can't stand. This
  # task grabs all of the premieres except for some genres
  Series-Premieres:
    priority: 40
    template:
      - tv-global
    # The entry has to have the tvdb_genres field so I can filter by it
    require_field:
      - tvdb_genres
      - tvdb_first_air_date
    # Make sure plenty of people are seeding it, otherwise it may not be that good
    torrent_alive:
      min_seeds: 30
    # Block these genres if they exist in the list of tvdb_genres at all
    regexp:
      reject:
        - documentary: {from: tvdb_genres}
        - talk show: {from: tvdb_genres}
        - game show: {from: tvdb_genres}
        - reality: {from: tvdb_genres}
        # - crime: {from: tvdb_genres}
        # - children: {from: tvdb_genres}
        # - home and garden: {from: tvdb_genres}
    if:
      # Block these genres only if they are the ONLY genre listed in
      # tvdb_genres. For example, this will not block a show that's both
      # "Comedy" and "Drama" but it will block a show that is just "Drama"
      - "tvdb_genres == ['Drama']": reject
      # Block premieres that weren't within the last 60 days
      - tvdb_first_air_date and tvdb_first_air_date < now - timedelta(days=60): reject
    # Accept all series permieres
    series_premiere:
      timeframe: 1 days
      quality: 720p|480p|1080p h264 # ac3|aac|mp3 ## maybe i'll get more premiere results now
    # Add to deluge, but don't queue to top (My_TV_Shows are more important)
    # and put in a different location
    set: 
      movedone: >
        {{ secrets.trakt.premieres_dir }}{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}/{% if series_id_type == 'ep' %}Season {{ series_season|pad(2) }}/{% endif %}
      queuetotop: no
      label: tv-premiere
    # This is a custom plugin, it is part of my rar-unpacking method, it changes
    # 'movedone' based on the regexp in the key
    content_sort: ##
      '*.rar': '{{ secrets.trakt.checkdir }'

  
  # If a premier was grabbed, keep on tracking it until the directory is (re)moved
  Series-Premieres-Track:
    priority: 50
    template:
      - tv-global
    configure_series:
      settings:
        target: 720p+ hdtv+
        timeframe: 3 days
        quality: 720p|480p|1080p h264 ac3|aac|mp3
        identified_by: ep
      from:
        filesystem: ##
          - '{{ secrets.trakt.premieres_dir }}'
    set: # see above
      movedone: >
        {{ secrets.trakt.premieres_dir }}{{ tvdb_series_name|default(series_name)|replace('/', '_')|replace(':', ' -')|replace(',', '')|replace(' ', '.') }}/{% if series_id_type == 'ep' %}Season.{{ series_season|pad(2) }}/{% endif %}
      queuetotop: no
      label: tv-premiere-track
    content_sort: ##
{'fraction_non_alphanumeric': 0.12221868196059689, 'fraction_numerical': 0.010939408422282406, 'mean_word_length': 2.3570728228897404, 'pattern_counts': {'":': 10, '<': 25, '<?xml version=': 0, '>': 39, 'https://': 8, 'lorem ipsum': 0, 'www.': 10, 'xml': 4}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1238327', 'n_tokens_mistral': 12209, 'n_tokens_neox': 11623, 'n_words': 3637}