Giter VIP home page Giter VIP logo

python-scripts-retifrav's Introduction

My Python scripts

Just some scripts I made to carry out certain tasks or try out various things.

ssh-known-hosts

SSH config known hosts analysis.

mp3-idv3-tags

Mass ID3v2 tags editing.

$ python mp3-idv3-tags.py /path/to/folder/with/mp3files/

generate-iconset

Moved to a separate repository.

oxps-to-pdf

Convert OXPS files into PDF. Requires ghostscript/gxps to be installed.

$ python oxps-to-pdf.py /path/to/folder/with/oxps/files

create-folders-for-files

I needed that to reorganize my Octopress blog posts to a new folder structure for Hugo.

Original structure:

.
├── first-post.md
├── ios-player-buttons-areas.md
├── gta-iv-final-mission-bug.md
├── sidebar-in-octopress.md
├── no-more-overlicensed.md
...

New structure:

.
├── first-post
│   └── index.md
├── ios-player-buttons-areas
│   └── index.md
├── gta-iv-final-mission-bug
│   └── index.md
├── sidebar-in-octopress
│   └── index.md
├── no-more-overlicensed
...

It takes only one argument which is the path to folder with the files you want to reorganize:

$ python create-folders-for-files.py ~/Desktop/posts/

tinyurl

A TinyURL API caller:

$ python tinyurl.py http://example.org

Part of my Alfred workflow.

folders-creation-datetimes

There is the following folders structure:

/tmp/revisions/
├── 37829
│   └── Tools
├── 37976
│   └── Tools
└── 37993
    └── Tools

Nov 24 18:30 37829/Tools
Nov 24 18:37 37976/Tools
Nov 24 18:31 37993/Tools

Need to get UTC datetimes of Tools folders and form a list of SQL queries for inserting like this:

insert into revisions(dt_published,release_id,revision,content_id) values('2019-11-24 17:31:07',1,'37993',3);
insert into revisions(dt_published,release_id,revision,content_id) values('2019-11-24 17:30:21',1,'37829',3);
insert into revisions(dt_published,release_id,revision,content_id) values('2019-11-24 17:37:17',1,'37976',3);

Run:

$ python folders-creation-datetimes.py /tmp/revisions/

get-possible-quiz-results

There is some online test and you want to get all the possible results. Having a results URL like http://mindmix.ru/result?t=23147&1=3&2=3&3=2&4=3&5=4&6=2&7=2&8=2&9=3&10=4, you can send a 1000 requests with random values.

coub-likes-list

Getting a list of liked coubs. Created for this issue/question.

Before running the script, replace the following:

  • aythenticationCookie: your actual Cookie HTTP header value, you get it from the browser console;
  • whereToSaveLikesList: path to the file where to save the list of links of your liked coubs;
    • optionally, also set whereToSaveLikesDetails and uncomment the block with json.dump()

Script is run without parameters:

$ python ./coub-likes-list.py

Once you have the resulting file with links, you can download all of them using CoubDownloader:

$ python /path/to/coub-downloader/coub.py /tmp/my-coub-likes.txt

pack-the-folder

Pack the current folder into a ZIP archive. Creates an archive in a folder one level up and then moves it into the current folder.

$ ls -L1 .
Screenshot1.png
Screenshot2.png
document.pdf
pack-the-folder.py
some/

$ python ./pack-the-folder.py

$ ls -L1 .
Screenshot1.png
Screenshot2.png
document.pdf
folder.zip
pack-the-folder.py
some/

srt-translation-generator

Creates a copy of an original SRT file, keeping only the titles numbers and time codes. The generated copy can be used for translating the original file.

$ python ./srt-translation-generator.py --help

normalize-filenames

Normalizing the names of files in a given directory:

  • replaces spaces and underscores with dashes
  • removes non-alphanumeric symbols
  • makes all letters small
$ ls -L1 /path/to/somewhere
Dota 2 WTF Moments 444.mkv
Johnny Depp Performs ‘Nothing Else Matters’ (Metallica Cover) During His Testimony, Then Wins Case.mkv
Video 4 Det snør!!!❄️❄️❄️❄️.mkv
dota-2-wtf-moments-444.mkv

$ python /path/to/normalize-filenames.py /path/to/somewhere --not-a-drill
THIS IS NOT A DRILL!
All the files in /path/to/somewhere folder will be renamed.
Hopefully, you've made a backup.

- renaming: Video 4 Det snør!!!❄️❄️❄️❄️.mkv
OK

- renaming: dota-2-wtf-moments-444.mkv
[WARNING] The file dota-2-wtf-moments-444.mkv already exists

- renaming: Johnny Depp Performs ‘Nothing Else Matters’ (Metallica Cover) During His Testimony, Then Wins Case.mkv
OK

- renaming: Dota 2 WTF Moments 444.mkv
[WARNING] The file dota-2-wtf-moments-444.mkv already exists

---
Total files processed: 2

$ ls -L1 /path/to/somewhere
Dota 2 WTF Moments 444.mkv
dota-2-wtf-moments-444.mkv
johnny-depp-performs-nothing-else-matters-metallica-cover-during-his-testimony-then-wins-case.mkv
video-4-det-snr.mkv

parallelization-example

An example of parallelizing some function.

$ python ./parallelization-example.py --help

python-scripts-retifrav's People

Contributors

retifrav avatar clock-drift avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.