Skip to content

Instantly share code, notes, and snippets.

Avatar
Embrace change

Ricardo Fernandes rickerp

Embrace change
  • MSc. Student @ Keio University & Instituto Superior Técnico, Universidade de Lisboa
  • Lisbon, Portugal
  • 14:23 (UTC +01:00)
View GitHub Profile
@rickerp
rickerp / m3u8converter.py
Created March 1, 2021 02:27
Python script that converts streaming links m3u8 to any types of video downloaded
View m3u8converter.py
#!/usr/bin/python
import subprocess
import argparse
import os
if os.system('which ffmpeg') != 0:
print('Please install ffmpeg before using this script')
print('sudo apt install ffmpeg')
exit(1)
@rickerp
rickerp / getfiles.py
Created February 28, 2021 20:35
Python script to recursively get files from html file server
View getfiles.py
#!/usr/bin/python
import re
import requests
import os
import argparse
ap = argparse.ArgumentParser()
ap.add_argument('URL', help='URL to download files')
ap.add_argument('regex', help='Regex to detect the subdirectories in html')
ap.add_argument("-d", "--directory", help="Directory", default=os.getcwd() + os.sep)
@rickerp
rickerp / dict_to_Q.py
Last active March 9, 2022 00:46
Django function to convert a dict to a Q object
View dict_to_Q.py
def dict_to_Q(filters_dict, valid_fields_operations=None, prefix=''):
"""
Converts a dictionary to Q filter object
Args:
filters_dict (dict):
Must contain fields, filter lookups and values.
Example: {'ts__gte': '2020-10-12', ...}
valid_fields_operations (dict, optional):
Mapping for valid field names and corresponding filter lookups.
Defaults to None : doesn't verify validity (insecure)