Skip to content

Commit

Permalink
Added logging with paths to result files
Browse files Browse the repository at this point in the history
  • Loading branch information
czifumasa committed Nov 6, 2020
1 parent 75f8161 commit f22d0c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
10 changes: 5 additions & 5 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

[EXPORT]
# Directory where results of the export will be saved
output_dir_export=output/export
output_dir_export=output\export

# When set to 1, then export of library won't be performed, changelog will be created for already existing csv files
skip_export=0

[CHANGELOG]
# Directory where results of the changelog will be saved
output_dir_changelog=output/changelog
output_dir_changelog=output\changelog

# When set to '1', then previous and current file will be automatically detected by using timestamps in filenames from the files in auto_detect_dir
# Set to 0, if you want to create changelog between specific files, provided in previous_file and current_file
auto_detect=1

# Directory where results of export are kept, used only when auto_detect is set to 1
auto_detect_dir=output/export
auto_detect_dir=output\export

# When auto_detect is set to 1, then this parameter is ignored.
# File with results of the previous export
previous_file=output/export/export_result_old.csv
previous_file=output\export\export_result_old.csv

# When auto_detect is set to 1, then this parameter is ignored.
# File with results of the current export
current_file=output/export/export_result_new.csv
current_file=output\export\export_result_new.csv

14 changes: 9 additions & 5 deletions ytmusiclibtracker/create_library_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def export_track_matches_to_csv_file(matches):
'VideoId', 'Matched_VideoId',
'SetVideoId', 'Matched_SetVideoId',
'PlaylistId', 'Matched_PlaylistId']
create_csv_with_list_of_dict(output_dir, 'change_log', headers, csv_rows, True)
return create_csv_with_list_of_dict(output_dir, 'change_log', headers, csv_rows, True)



def get_sort_function_for_track_matches():
Expand Down Expand Up @@ -124,9 +125,11 @@ def create_library_changelog():
initialize_global_params_from_config_file()
if previous_export_file and current_export_file:

log('Previous export file: ' + previous_export_file)
log('Previous export file: ')
log(os.path.abspath(previous_export_file), True)
previous_song_rows = import_track_records_from_csv_file(previous_export_file)
log('\nCurrent export file: ' + current_export_file, True)
log('Current export file: ')
log(os.path.abspath(current_export_file), True)
log('Creating changelog...', True)
current_song_rows = import_track_records_from_csv_file(current_export_file)

Expand All @@ -136,8 +139,9 @@ def create_library_changelog():
changelog_results = track_matches + duplicates
# setup the output directory, create it if needed
create_dir_if_not_exist(output_dir)
export_track_matches_to_csv_file(changelog_results)
log('Changelog has been created.', True)
filename = export_track_matches_to_csv_file(changelog_results)
log('Changelog has been created. File with results has been saved in:')
log(filename, True)
elif (not previous_export_file) and current_export_file:
log('Changelog skipped. Only one export file exists.', True)
else:
Expand Down
1 change: 1 addition & 0 deletions ytmusiclibtracker/csv_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def create_csv_with_list_of_dict(output_dir, filename, headers, list_of_rows, wi
file_writer.writerow(headers)
for row in list_of_rows:
file_writer.writerow(row)
return os.path.abspath(full_name)


def get_list_of_rows_from_file(filename):
Expand Down
4 changes: 3 additions & 1 deletion ytmusiclibtracker/export_playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def export_to_csv():
# setup the output directory, create it if needed
create_dir_if_not_exist(output_dir)
headers = get_ytmlt_export_headers()
create_csv_with_list_of_dict(output_dir, 'exported_songs', headers, export_result, True)
filename = create_csv_with_list_of_dict(output_dir, 'exported_songs', headers, export_result, True)
log('Export has been completed. File with results has been saved in:')
log(filename, True)
return export_result
log('Export has been skipped. If you want to export again, open config.ini file and edit option: skip_export=0', True)
return []
Expand Down

0 comments on commit f22d0c3

Please sign in to comment.