Skip to content

Instantly share code, notes, and snippets.

View hiroshil's full-sized avatar
💭
I may be slow to respond.

Hiroshi hiroshil

💭
I may be slow to respond.
View GitHub Profile
@hiroshil
hiroshil / od_up.py
Created November 29, 2024 07:32
Script to upload a file to a OneDrive folder using Office365-REST-Python-Client (with Tqdm progress bar and resumable upload supported)
import os
import re
import json
from tqdm import tqdm
from pathlib import Path
from office365.graph_client import GraphClient
from office365.onedrive.internal.paths.url import UrlPath
from office365.onedrive.driveitems.driveItem import DriveItem
from office365.onedrive.driveitems.uploadable_properties import (
DriveItemUploadableProperties,
@hiroshil
hiroshil / gdrive_down.py
Last active April 7, 2025 13:20
Script to download files or folders from Google Drive using PyDrive2 (with Tqdm progress bar and resumable download supported)
import re
import os
from tqdm import tqdm as Tqdm
from typing import Any, ClassVar
from googleapiclient import errors
from googleapiclient.http import MediaIoBaseDownload
from googleapiclient import _helpers as util
from pydrive2.auth import GoogleAuth, LoadAuth
from pydrive2.drive import GoogleDrive
from pydrive2.files import GoogleDriveFile, FileNotUploadedError, ApiRequestError
@hiroshil
hiroshil / gdrive_up.py
Last active November 27, 2024 02:45
Script to upload files or folders to a Google Drive folder using PyDrive2 (with Tqdm progress bar supported)
import re
from pathlib import Path
from tqdm import tqdm as Tqdm
from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive
param = "FolderID" #FileID is the simple file hash, like 0B1NzlxZ5RpdKS0NOS0x0Ym9kR0U
err_fmt = False
if len(param) > 33:
match = re.search(r"https:\/\/drive\.google\.com\/drive\/folders\/([^/]+)\/view\?usp=drive_link", param)
@hiroshil
hiroshil / n210-dl.user.js
Last active April 27, 2024 10:36
Script to download manga on some domain of nhentai into a zip file (Note: Requires "Allow CORS" extension with "Access-Control-Allow-Origin" mode set to "*" in options page for script to work)
// ==UserScript==
// @name n210-dl
// @namespace https://gist.github.com/hiroshil
// @version 0.1.1
// @description Script used to download manga R18 on some domain of nhentai
// @license MIT
// @author hiroshil
// @source https://gist.github.com/hiroshil/86723bc557efa88931cf6b135e42a2b2
// @match http*://nhentai.to/g/*
// @match http*://nhentai.xxx/g/*
@hiroshil
hiroshil / Merge2010.py
Created April 6, 2024 03:41
Description is in the comment below
import sys
import numpy as np
from pathlib import Path
from PIL import Image
def process_file(file_path):
"""
Reads lines from a file, splits each line by dot, creates tuples with the first and second elements,
and appends them to a result array.
@hiroshil
hiroshil / 210vn-dl.user.js
Last active August 10, 2024 15:00
Script download manga trên 1 domain của hentaivn thành một file zip (Lưu ý: cần cài thêm extension "Allow CORS" và bật chế độ "Access-Control-Allow-Origin" từ "ORIGIN" sang "*" trong trang tùy chọn để script có thể hoạt động)
// ==UserScript==
// @name 210vn-dl
// @namespace https://gist.github.com/hiroshil
// @version 0.0.6
// @description Script dùng để download manga R18 trên 1 domain của hentaivn
// @license MIT
// @author hiroshil
// @source https://gist.github.com/hiroshil/b85af14867493a72bd1cb24831bf0668
// @include http*://*.*/*doc-truyen*
// @icon https://www.google.com/s2/favicons?sz=64&domain=hentaivn.icu
@hiroshil
hiroshil / tmo-dl.user.js
Last active January 31, 2024 17:21
Script to download manga from TuMangaOnline into a zip file (Note: Requires "Allow CORS" extension with "Access-Control-Allow-Origin" mode set to "*" in options page for script to work). This script was created in my free time and may not be updated regularly.
// ==UserScript==
// @name tmo-dl
// @namespace https://gist.github.com/hiroshil
// @version 1.0
// @description Script to download manga from TuMangaOnline
// @license MIT
// @author hiroshil
// @match https://visortmo.com/library/manga/*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=visortmo.com
// @downloadURL https://gist.github.com/hiroshil/6c4360a56dd37a788646c468fe2ef7fc/raw/3fb7e6fde2dabe3fb4198eda17cce25db89c9dfa/tmo-dl.user.js
@hiroshil
hiroshil / Upload_SPO.py
Created December 3, 2023 04:05
Upload file folders to Sharepoint Online/Onedrive Business using Office365-REST-Python-Client
import os
import math
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.runtime.client_request_exception import ClientRequestException
from office365.sharepoint.client_context import ClientContext
baseurl = "https://test-my.sharepoint.com" # sp url
basesite = "admin_test_onmicrosoft_com" # sp site name
siteurl = baseurl + "/personal/" + basesite # sp site type: personal, teams, sites
username = "email"
@hiroshil
hiroshil / fod_get.py
Last active November 12, 2023 19:08
Retrieve list of folder from Onedrive folder share link and generate direct download links
import base64
import json
import requests
# https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get?view=odsp-graph-online
# https://stackoverflow.com/questions/40454101/access-publicly-shared-onedrive-folder-via-api
# https://stackoverflow.com/questions/19483351/converting-json-string-to-dictionary-not-list
sharing_url = "PUT_SHARE_LINK_HERE"
exclude = []
def download_folder(sharing_url, parent_name=''):
base64_value = base64.b64encode(sharing_url.encode('utf-8')).decode('utf-8')
@hiroshil
hiroshil / fsp_get.py
Last active December 24, 2023 17:30
Retrieve list of folder from SharePoint folder share link and generate direct download links. (Requirement: xmltodict)
import re
import requests, json
from urllib import parse
import xmltodict
# https://sharepoint.stackexchange.com/questions/238013/get-list-of-files-from-sharepoint-folder-by-url
# https://stackoverflow.com/questions/25091976/python-requests-get-cookies
# https://github.com/juju/python-libjuju/blob/master/juju/client/gocookies.py
# https://stackoverflow.com/questions/13030095/how-to-save-requests-python-cookies-to-a-file
# https://stackoverflow.com/questions/71576413/saving-data-to-a-json-file-using-python
# https://stackoverflow.com/questions/8628152/url-decode-with-python-3