Compare commits
2 commits
106b75ca62
...
4dee7757a5
Author | SHA1 | Date | |
---|---|---|---|
4dee7757a5 | |||
feca571985 |
3 changed files with 134 additions and 1 deletions
|
@ -1,2 +1,5 @@
|
|||
# QuteBrowser QuickMarks Browser #
|
||||
QBQMB est un navigateur de favoris (quickmarks) pour le navigateur QuteBrowser. Il est écrit en bash, et sa seule dépendance est dialog.
|
||||
QBQMB est un navigateur de favoris (quickmarks) pour le navigateur QuteBrowser. Il est écrit en bash, et sa seule dépendance est dialog
|
||||
|
||||
# QuteBrowser To Firefox #
|
||||
qbtoff-fr.py est un script permettant de convertir les marques pages de QuteBrowser (quickmarks) vers un fichier HTML importable sur Firefox et ses dérivés (testé avec Waterfox OK). Cela doit aussi fonctionner avec Chrome (pas testé).
|
||||
|
|
65
qbqmb/qbtoff-en.py
Normal file
65
qbqmb/qbtoff-en.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
from urllib.parse import urlparse
|
||||
|
||||
# Function to generate a bookmark line in HTML format
|
||||
def generate_bookmark(title, url):
|
||||
return f'<DT><A HREF="{url}" ADD_DATE="">{title}</A>\n'
|
||||
|
||||
# Dictionary to store folders and their bookmarks
|
||||
folders = {}
|
||||
|
||||
# Path to your source file
|
||||
file_path = 'bookmarks.txt'
|
||||
|
||||
# Read the file and process each line
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
default_folder = "Others" # Default folder for lines without a folder prefix
|
||||
|
||||
urls_seen = set()
|
||||
|
||||
for line in lines:
|
||||
line = line.strip() # Remove leading/trailing whitespace
|
||||
parts = line.rsplit(" ", 1) # Split URL from the rest of the line
|
||||
if len(parts) == 2:
|
||||
url = parts[-1]
|
||||
if url not in urls_seen:
|
||||
urls_seen.add(url)
|
||||
title = parts[0]
|
||||
if " - " in title:
|
||||
folder_name = title.split(" - ", 1)[0] # Extract folder name
|
||||
title = title.split(" - ", 1)[1] # Extract title without folder prefix
|
||||
else:
|
||||
folder_name = default_folder
|
||||
if folder_name not in folders:
|
||||
folders[folder_name] = []
|
||||
folders[folder_name].append(generate_bookmark(title, url))
|
||||
else:
|
||||
print(f"Ignored duplicate: {line}")
|
||||
else:
|
||||
# Handle malformed or improperly formatted lines
|
||||
print(f"Ignored line: {line}")
|
||||
|
||||
# Generate HTML content
|
||||
html_content = """<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||
<TITLE>Imported Bookmarks</TITLE>
|
||||
<H1>Imported Bookmarks</H1>
|
||||
<DL><p>\n"""
|
||||
|
||||
# Add folders and their bookmarks to the HTML content
|
||||
for folder, bookmarks in folders.items():
|
||||
html_content += f'<DT><H3>{folder}</H3>\n<DL><p>\n'
|
||||
for bookmark in bookmarks:
|
||||
html_content += bookmark
|
||||
html_content += "</DL><p>\n"
|
||||
|
||||
html_content += "</DL><p>\n"
|
||||
|
||||
# Write content to an HTML file
|
||||
output_file = "bookmarks.html"
|
||||
with open(output_file, "w", encoding="utf-8") as file:
|
||||
file.write(html_content)
|
||||
|
||||
print(f"Conversion completed. HTML file generated successfully: {output_file}")
|
||||
|
65
qbqmb/qbtoff-fr.py
Normal file
65
qbqmb/qbtoff-fr.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
from urllib.parse import urlparse
|
||||
|
||||
# Fonction pour générer une ligne de marque-page au format HTML
|
||||
def generate_bookmark(title, url):
|
||||
return f'<DT><A HREF="{url}" ADD_DATE="">{title}</A>\n'
|
||||
|
||||
# Dictionnaire pour stocker les dossiers et leurs marque-pages
|
||||
folders = {}
|
||||
|
||||
# Chemin vers votre fichier source
|
||||
file_path = '/home/t0mux/Sync/Conf/qb/quickmarks'
|
||||
|
||||
# Lecture du fichier et traitement des lignes
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
default_folder = "Autres" # Dossier par défaut pour les lignes sans préfixe de dossier
|
||||
|
||||
urls_seen = set()
|
||||
|
||||
for line in lines:
|
||||
line = line.strip() # Supprime les espaces inutiles autour de la ligne
|
||||
parts = line.rsplit(" ", 1) # Sépare l'URL du reste de la ligne
|
||||
if len(parts) == 2:
|
||||
url = parts[-1]
|
||||
if url not in urls_seen:
|
||||
urls_seen.add(url)
|
||||
title = parts[0]
|
||||
if " - " in title:
|
||||
folder_name = title.split(" - ", 1)[0] # Extrait le nom du dossier
|
||||
title = title.split(" - ", 1)[1] # Extrait le titre sans le dossier
|
||||
else:
|
||||
folder_name = default_folder
|
||||
if folder_name not in folders:
|
||||
folders[folder_name] = []
|
||||
folders[folder_name].append(generate_bookmark(title, url))
|
||||
else:
|
||||
print(f"Doublon ignoré : {line}")
|
||||
else:
|
||||
# Gérer les lignes mal formées ou non conformes au format attendu
|
||||
print(f"Ligne ignorée : {line}")
|
||||
|
||||
# Génère le contenu HTML
|
||||
html_content = """<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||
<TITLE>Marque-pages importés</TITLE>
|
||||
<H1>Marque-pages importés</H1>
|
||||
<DL><p>\n"""
|
||||
|
||||
# Ajoute les dossiers et leurs marque-pages au contenu HTML
|
||||
for folder, bookmarks in folders.items():
|
||||
html_content += f'<DT><H3>{folder}</H3>\n<DL><p>\n'
|
||||
for bookmark in bookmarks:
|
||||
html_content += bookmark
|
||||
html_content += "</DL><p>\n"
|
||||
|
||||
html_content += "</DL><p>\n"
|
||||
|
||||
# Écrit le contenu dans un fichier HTML
|
||||
output_file = "marque_pages.html"
|
||||
with open(output_file, "w", encoding="utf-8") as file:
|
||||
file.write(html_content)
|
||||
|
||||
print(f"Conversion terminée. Fichier HTML généré avec succès : {output_file}")
|
||||
|
Loading…
Reference in a new issue