Skip to content

A Python program for encoding urls using filename-valid (Win/Mac/Lin) characters in a human-readable way.

License

Notifications You must be signed in to change notification settings

usernyan/url-as-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

url-as-file

A Python program for encoding urls using filename-valid (Win/Mac/Lin) characters in a human-readable way.

Purpose

This program was written to allow saving images from the web with their source url in the filename.

It replaces unwanted characters (\/<>:*?"|.) with filename-valid ones ({}[];+`'~,). These replacement characters are encoded with an escape character (!) before it. That is, the text Sharp and Curly: <> {} ; becomes Sharp and Curly; [] !{!} !;

Interactive Program

First, install python (python.org)

Next, run url_as_file_interactive.py and follow the prompts to encode or decode text in your terminal.

Command-line Interface

Run python url_as_file_cmd.py -h in your terminal for help.

Usage (For Programmers)

Import url_as_file and codecs to start decoding and encoding strings in python:

import url_as_file
import codecs

my_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
result = codecs.encode(my_url, 'url-as-file')
print(result)
decode = codecs.decode(result, 'url-as-file')
print(decode)

Output:

https;}}www,youtube,com}watch`v=dQw4w9WgXcQ
https://www.youtube.com/watch?v=dQw4w9WgXcQ

About

A Python program for encoding urls using filename-valid (Win/Mac/Lin) characters in a human-readable way.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages