def recheck_dupe(searchstrs, metadata): new_searchstrs = generate_dupe_check_searchstrs(metadata["artists"], metadata["title"], metadata["catno"]) if (searchstrs and any(n not in searchstrs for n in new_searchstrs) or not searchstrs and new_searchstrs): click.secho( "\nRechecking for duplicates on RED due to metadata changes...", fg="cyan", bold=True, ) return check_existing_group(new_searchstrs)
def recheck_dupe(gazelle_site, searchstrs, metadata): new_searchstrs = generate_dupe_check_searchstrs(metadata["artists"], metadata["title"], metadata["catno"]) if (searchstrs and any(n not in searchstrs for n in new_searchstrs) or not searchstrs and new_searchstrs): click.secho( f'\nRechecking for dupes on {gazelle_site.site_string} ' 'due to metadata changes...', fg="cyan", bold=True, nl=False, ) return check_existing_group(gazelle_site, new_searchstrs)
def upload( gazelle_site, path, group_id, source, lossy, spectrals, encoding, existing=None, overwrite_meta=False, recompress=False, source_url=None, searchstrs=None, request_id=None, spectrals_after=False, ): """Upload an album folder to Gazelle Site Offer the choice to upload to another tracker after completion.""" path = os.path.abspath(path) if not source: source = _prompt_source() audio_info = gather_audio_info(path) hybrid = check_hybrid(audio_info) standardize_tags(path) tags = gather_tags(path) rls_data = construct_rls_data( tags, audio_info, source, encoding, existing=existing, overwrite=overwrite_meta, prompt_encoding=True, ) try: if rls_data["encoding"] == "24bit Lossless" and click.confirm( click.style( "24bit detected. Do you want to check whether might be upconverted?", fg="magenta", ), default=True, ): upload_upconvert_test(path) if group_id is None: searchstrs = generate_dupe_check_searchstrs( rls_data["artists"], rls_data["title"], rls_data["catno"]) group_id = check_existing_group(gazelle_site, searchstrs) if spectrals_after: lossy_master = False # We tell the uploader not to worry about it being lossy until later. else: lossy_master, spectral_ids = check_spectrals( path, audio_info, lossy, spectrals) metadata = get_metadata(path, tags, rls_data) download_cover_if_nonexistent(path, metadata["cover"]) path, metadata, tags, audio_info = edit_metadata( path, tags, metadata, source, rls_data, recompress) if not group_id: group_id = recheck_dupe(gazelle_site, searchstrs, metadata) click.echo() track_data = concat_track_data(tags, audio_info) except click.Abort: return click.secho(f"\nAborting upload...", fg="red") except AbortAndDeleteFolder: shutil.rmtree(path) return click.secho(f"\nDeleted folder, aborting upload...", fg="red") lossy_comment = None if spectrals_after: spectral_urls = None else: if lossy_master: lossy_comment = generate_lossy_approval_comment( source_url, list(track_data.keys())) click.echo() spectrals_path = os.path.join(path, "Spectrals") spectral_urls = handle_spectrals_upload_and_deletion( spectrals_path, spectral_ids) # Shallow copy to avoid errors on multiple uploads in one session. remaining_gazelle_sites = list(salmon.trackers.tracker_list) tracker = gazelle_site.site_code while True: # Loop until we don't want to upload to any more sites. if not tracker: if spectrals_after: # Here we are checking the spectrals after uploading to the first site # if they were not done before. lossy_master, lossy_comment, spectral_urls = post_upload_spectral_check( gazelle_site, path, torrent_id, None, track_data, source, source_url) spectrals_after = False click.secho("Would you like to upload to another tracker? ", fg="magenta", nl=False) tracker = salmon.trackers.choose_tracker(remaining_gazelle_sites) gazelle_site = salmon.trackers.get_class(tracker)() click.secho(f"Uploading to {gazelle_site.base_url}", fg="cyan") searchstrs = generate_dupe_check_searchstrs( rls_data["artists"], rls_data["title"], rls_data["catno"]) group_id = check_existing_group(gazelle_site, searchstrs, metadata) remaining_gazelle_sites.remove(tracker) if not request_id and config.CHECK_REQUESTS: request_id = check_requests(gazelle_site, searchstrs) torrent_id = prepare_and_upload( gazelle_site, path, group_id, metadata, track_data, hybrid, lossy_master, spectral_urls, lossy_comment, request_id, ) if lossy_master: report_lossy_master( gazelle_site, torrent_id, spectral_urls, track_data, source, lossy_comment, source_url=source_url, ) url = "{}/torrents.php?torrentid={}".format(gazelle_site.base_url, torrent_id) click.secho( f"\nSuccessfully uploaded {url} ({os.path.basename(path)}).", fg="green", bold=True, ) if config.COPY_UPLOADED_URL_TO_CLIPBOARD: pyperclip.copy(url) tracker = None request_id = None if not remaining_gazelle_sites or not config.MULTI_TRACKER_UPLOAD: return click.secho(f"\nDone uploading this release.", fg="green")
def upload( path, group_id, source, lossy, spectrals, encoding, existing=None, overwrite_meta=False, recompress=False, source_url=None, searchstrs=None, ): """Upload an album folder to RED""" path = os.path.abspath(path) if not source: source = _prompt_source() audio_info = gather_audio_info(path) hybrid = check_hybrid(audio_info) standardize_tags(path) tags = gather_tags(path) rls_data = construct_rls_data( tags, audio_info, source, encoding, existing=existing, overwrite=overwrite_meta, prompt_encoding=True, ) try: if group_id is None: searchstrs = generate_dupe_check_searchstrs( rls_data["artists"], rls_data["title"], rls_data["catno"]) group_id = check_existing_group(searchstrs) lossy_master, spectral_ids = check_spectrals(path, audio_info, lossy, spectrals) metadata = get_metadata(path, tags, rls_data) download_cover_if_nonexistent(path, metadata["cover"]) path, metadata, tags, audio_info = edit_metadata( path, tags, metadata, source, rls_data, recompress) if not group_id: group_id = recheck_dupe(searchstrs, metadata) click.echo() track_data = concat_track_data(tags, audio_info) except click.Abort: return click.secho(f"\nAborting upload...", fg="red") except AbortAndDeleteFolder: shutil.rmtree(path) return click.secho(f"\nDeleted folder, aborting upload...", fg="red") lossy_comment = None if lossy_master: lossy_comment = generate_lossy_approval_comment( source_url, list(track_data.keys())) click.echo() spectrals_path = os.path.join(path, "Spectrals") spectral_urls = handle_spectrals_upload_and_deletion( spectrals_path, spectral_ids) torrent_id, group_id = prepare_and_upload( path, group_id, metadata, track_data, hybrid, lossy_master, spectral_urls, lossy_comment, ) if lossy_master: report_lossy_master( torrent_id, spectral_urls, track_data, source, lossy_comment, source_url=source_url, ) url = f"https://redacted.ch/torrents.php?id={group_id}&torrentid={torrent_id}" click.secho( f"\nSuccessfully uploaded {url} ({os.path.basename(path)}).", fg="green", bold=True, ) if config.COPY_UPLOADED_URL_TO_CLIPBOARD: pyperclip.copy(url)