Skip to content

Commit

Permalink
Fix Plex not updating on completion and formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Shelley committed Jul 7, 2019
1 parent 0ec9225 commit 6327754
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# All notable changes to this project will be documented in this file.
# This project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.7-beta] 2019-07-07
- Fix Plex not updating on completion
- Fix progress bar not formatting correctly
- Hide progress bar updating in plaintext mode

## [0.2.6-beta] 2019-07-05
- Add support for Python 3.5 and 3.7 (3.6 already supported)
- Clean up and future-proofing for later versions of dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![version](https://img.shields.io/badge/version-0.2.6--beta-green.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8fcfaf45a6494aedb4b0340461c2b79b)](https://www.codacy.com/app/brandonscript/fylm) [![Build Status](https://travis-ci.org/brandonscript/fylm.svg?branch=master)](https://travis-ci.org/brandonscript/fylm)
![version](https://img.shields.io/badge/version-0.2.7--beta-green.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8fcfaf45a6494aedb4b0340461c2b79b)](https://www.codacy.com/app/brandonscript/fylm) [![Build Status](https://travis-ci.org/brandonscript/fylm.svg?branch=master)](https://travis-ci.org/brandonscript/fylm)

<img src="https://i.imgur.com/X53grFH.png" width="200">

Expand Down
2 changes: 1 addition & 1 deletion fylm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import fylmlib.notify as notify
import fylmlib.counter as counter

__version__ = '0.2.6-beta'
__version__ = '0.2.7-beta'

def main():
"""Main program."""
Expand Down
7 changes: 4 additions & 3 deletions fylm/fylmlib/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def print_search_result(self, film):
if film.tmdb_id is not None:
c = console().indent()
c.green(f'✓ {film.title} ({film.year})')
c.dark_gray(f' [{film.tmdb_id}] {formatter.percent(film.title_similarity)} match')
c.dark_gray(f' [{film.tmdb_id}] {formatter.percent(film.title_similarity)}% match')
c.print()
else:
console().red().indent(f'× {film.title} ({film.year})').print()
Expand Down Expand Up @@ -294,8 +294,9 @@ def print_move_or_copy(self, src, dst_path, dst):
def print_copy_progress_bar(self, copied, total):
"""Print progress bar to terminal.
"""
print(' ' + progress.progress_bar(100 * copied / total), end='\r')
sys.stdout.flush()
if not config.plaintext:
print(' ' + progress.progress_bar(100 * copied / total), end='\r')
sys.stdout.flush()

@classmethod
def get_input(cls, prompt):
Expand Down
4 changes: 2 additions & 2 deletions fylm/fylmlib/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def plex():
# in live mode. No need to notify in test mode since there won't be any changes.
if not config.test:
for section in (plex.library.section(section) for section in config.plex.sections):
section.update()
section.refresh()

console().green(' Done ✓').print()
console().green(' Done ✓\n').print()

# Re-enable logging when done.
log.enable()
Expand Down
8 changes: 4 additions & 4 deletions fylm/fylmlib/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def progress_bar(percentage, width=50):
"""

if config.plaintext:
FULL_BLOCK = color('X', fg=ansi.pink)
INCOMPLETE_BLOCK_GRAD = [color('-', fg=ansi.dark_gray), color('-', fg=ansi.dark_gray), color('=', fg=ansi.dark_gray)]
FULL_BLOCK = "X"
INCOMPLETE_BLOCK_GRAD = ["-", "-", "="]
else:
FULL_BLOCK = color('█', fg=ansi.pink)
INCOMPLETE_BLOCK_GRAD = [color('░', fg=ansi.dark_gray), color('▒', fg=ansi.dark_gray), color('▓', fg=ansi.dark_gray)]
Expand Down Expand Up @@ -78,10 +78,10 @@ def progress_bar(percentage, width=50):
blocks_widget[full_blocks] = INCOMPLETE_BLOCK_GRAD[grad_index]

# Build percentage widget
str_perc = f'{percentage}.0f'
str_perc = f'{percentage:.1f}'

# Subtract 1 because the percentage sign is not included.
perc_widget = f'{str_perc.ljust(len(max_perc_widget) - 3)}%%'
perc_widget = f'{str_perc.ljust(len(max_perc_widget) - 3)}%'

# Generate progress bar
progress_bar = f"{''.join(blocks_widget)}{separator}{perc_widget}"
Expand Down
2 changes: 1 addition & 1 deletion fylm/tests/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_plex(self):
plex = PlexServer(baseurl=config.plex.baseurl, token=config.plex.token, timeout=10)

for section in (plex.library.section(section) for section in config.plex.sections):
section.update()
section.refresh()

@pytest.mark.xfail(raises=(OSError, IOError))
def test_plex_fail(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
setup(
name='Fylm',

version='0.2.6-beta',
version='0.2.7-beta',

description='A automated command line app for organizing your film media.',
long_description=long_description,
Expand Down

0 comments on commit 6327754

Please sign in to comment.