Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
[07.03.21] FIX: Some small fixes to code.
Browse files Browse the repository at this point in the history
  • Loading branch information
romanoh committed Mar 7, 2021
1 parent 14ab88c commit 30f6194
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 40 deletions.
6 changes: 3 additions & 3 deletions ABtorrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import sys
import logging

script_version = 'Beta v.0.2.8 - ABtorrents uploader Helper'
script_version_short = 'Beta v.0.2.8'
script_version = 'Beta v.0.2.9 - ABtorrents uploader Helper'
script_version_short = 'Beta v.0.2.9'

# set up logging to file -------------------------------------------------------------------
logging.basicConfig(level=logging.INFO,
Expand Down Expand Up @@ -80,7 +80,7 @@ def show_exception_and_exit(exc_type, exc_value, tb):


sys.excepthook = show_exception_and_exit
# END If error pauses script---------------------------------------------------
# END If error pauses script-----------------------------------------------


# Log Version--------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Beta v.0.2.8 - [UNRELEASED]
[01.03.21] FIX: Fix a bug in mp3 link tag.
[01.03.21] FIX: Fix a bug in mp3 encoder tag.


Beta v.0.2.7
[28.02.21] STR: Still improving log system.
[27.02.21] STR: Working on implementing: if nfo present get first metadata from it.
Expand Down
63 changes: 27 additions & 36 deletions search_in_nfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,56 +76,30 @@ def find_files(directory, pattern):
logger_nfo.info('Metadata will be made from audio file metadata.')
pass
# -------------------------------------------------------------------------------
try:
search_album = 'Title:'


except:
search_album = 'TiTlE......:'

search_album = ['TiTlE2', 'Title:', 'TiTlE......:']

try:
search_author = 'AUTHOR.....:'
except:
search_author = 'Author:'
search_author = 'AUTHOR.....:'
search_author = 'Author:'

try:
search_narr = 'Read By:'
except NameError:
search_narr = 'READ BY....:'
except:
search_narr = 'Narrator:'
search_narr = 'Read By:'
search_narr = 'READ BY....:'
search_narr = 'Narrator:'

search_copyright = 'Copyright:'
search_genre = 'Genre:'
search_duration = 'Duration:'
search_publisher = 'Publisher:'
search_unabridged = 'Unabridged:'

# Series
search_series = 'Series: '
search_series = 'Series Name:'

# Series number
# search_series_num = 'Series'
search_series_num = 'Position in Series:'

search_release = 'Release:'
search_size = 'Size:'

time.sleep(1)
logger_nfo.info('Searching Author...')
# search author
matched_lines = search_string_in_file(nfofile, search_author)
logger_nfo.info('Total Matched lines: %s', len(matched_lines))
for elem in matched_lines:
linha = elem[0]
author = elem[1]
# remove everything after :
nfo_author = re.sub(r'^[^:]*:', r'', author).lstrip().title()
time.sleep(1)
logger_nfo.info('Author found: %s', nfo_author)
time.sleep(1)
# --------------------------------------------------------------------------

logger_nfo.info('Searching Title book...')
time.sleep(1)
Expand All @@ -135,17 +109,35 @@ def find_files(directory, pattern):
for elem2 in matched_lines2:
linha2 = elem2[0]
title = elem2[1]
print(title)
# remove (Unabridged)
nfo_album = re.sub(r'(Unabridged)', r'', title)
# remove - Book 1
nfo_album = re.sub(r'- Book 1', r'', nfo_album)
# retirar tudo antes do char :
nfo_album = re.sub(r'^[^:]*:', r'', nfo_album).lstrip().title()
# if book as series
print(nfo_album)
nfo_album2 = nfo_album.split(' - ')
nfo_album = nfo_album2[1]
try:
nfo_album = nfo_album2[1]
except:
pass
logger_nfo.info('Book found: %s', nfo_album)

logger_nfo.info('Searching Author...')
# search author
matched_lines = search_string_in_file(nfofile, search_author)
logger_nfo.info('Total Matched lines: %s', len(matched_lines))
for elem in matched_lines:
linha = elem[0]
author = elem[1]
# remove everything after :
print('author', author)
nfo_author = re.sub(r'^[^:]*:', r'', author).lstrip().title()
time.sleep(1)
logger_nfo.info('Author found: %s', nfo_author)
time.sleep(1)

logger_nfo.info('Searching narrator...')
time.sleep(1)
Expand Down Expand Up @@ -214,7 +206,6 @@ def find_files(directory, pattern):
logger_nfo.info('Series number found: %s', num_serie)
time.sleep(1)


# search_genre Type
logger_nfo.info('Searching Genre...')
time.sleep(1)
Expand Down Expand Up @@ -353,4 +344,4 @@ def find_files(directory, pattern):
# logger_nfo.info('Description: %s', join)
print(join)
# else:
# print('No description found.')
# print('No description found.')

0 comments on commit 30f6194

Please sign in to comment.