I'm trying to retrieve the @ from a string, for example: https://prnt.sc/DLoqh8x5L0EB
I'm currently retrieving the IDs, but it would save me a lot of time to be able to retrieve the @s to copy and paste the youtube links into my storage file.
I'd like to specify that I want to retrieve the tag and id so that I can use it in my data.yml, not to display it, since I'm already displaying the ID for strings with an ID. Ideally, I'd like to display the TAG, but as a first step, if my data.yml can retrieve a URL containing a tag, that would be a big step.
The aim is to quickly retrieve public information in order to develop a communication campaign.I have a "data.yml" storage file to store youtube channel links.as well as a result file to use these results
I want to retrieve the @ (TAG) as well as the ID because some channels still have the ID and it would save me time to have them both.Example :ID = AUIGDHBNDJ18632Y1NS@ or TAG = @MrBeast
I've tried various things but nothing conclusive. I've been working on this project for say 2 - 3 days and I'm completely at a loss if anyone has a solution I'd love to hear from you.
with open('data/data.yml', 'r') as yaml_file: data = yaml.safe_load(yaml_file)channel_urls = [channel['url'] for channel in data['channels']]youtube = build('youtube', 'v3', developerKey=api_key)channel_results = []for channel_url in channel_urls: channel_id = channel_url.split('/')[-1] try: # Votre code existant pour récupérer les informations de la chaîne channel_info = {'url': channel_url,'id': channel_id, # Autres informations de la chaîne récupérées } channel_results.append(channel_info) # Affichage des informations de la chaîne print(f"Nombre de chaînes : {len(channel_results)}\n") print("URL de la chaîne :", channel_url) print("ID de la chaîne :", channel_id) # Autres informations à afficher print() except Exception as e: print("Une erreur s'est produite lors de la récupération des informations de la chaîne :", channel_url) print("Erreur :", str(e)) print()# Écrire le nombre de chaînes en première ligne du fichier résultatwith open('output/channel_results.yml', 'w', encoding='utf-8') as yaml_file: yaml_file.write(f"Nombre de chaînes : {len(channel_results)}\n") yaml.dump({'channels': channel_results}, yaml_file, allow_unicode=True)