{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "OneClickRun.ipynb",
      "provenance": [],
      "collapsed_sections": [
        "QRKdKW2SRc23",
        "NuyWhC0U_Dzv",
        "znqEQoWfTjGx",
        "AOrO7nJ_7wjh",
        "VDInERXVmnm8",
        "PE5J1UDzQXSp",
        "fJ7W2Z0gcYa5",
        "Ttv0CeCqLX0t",
        "u5gtC3WRH5o-",
        "9KIWnL2jCRB-",
        "kSvUMUuTPX7r",
        "yOnMe4O3jtXf",
        "7U8mMA7ZBRMl",
        "wZMZjX127rmx",
        "F4eLcy-vYZia",
        "yQGcOoAJJOZV",
        "m5jM8gHbzWUW",
        "i5K4z5KBuGEx",
        "4rMlpsk3jv5r",
        "FVvFaJrZ0bxg",
        "qtAvLGCMBx1L",
        "gz_8S4IOni_1",
        "VSJRUHS7OZUJ",
        "INCWjTDRLye6",
        "fhhDx-Svhrp3",
        "HsvEZZy0hrp6",
        "0ZvyevbbU1Lb",
        "ECEW6SBqLazX",
        "Z1YQc9zZ45wW",
        "yL1BRPGVwfbt",
        "1EP1o4UDLS6f",
        "bOOBrzjbEGo_"
      ],
      "machine_shape": "hm",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/biplobsd/OneClickRun/blob/master/OneClickRun.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "QRKdKW2SRc23"
      },
      "source": [
        "# <center><a href=\"https://t.me/torrentToGM\"><img src='https://i.imgur.com/CLg6blO.png' height=\"70\" alt=\"Telegram Group\"/></a><a href=\"https://github.com/biplobsd/OneClickRun\"><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Ei-sc-github.svg/768px-Ei-sc-github.svg.png' height=\"80\" alt=\"Github\"/></a><img src=\"https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fgithub.com%2Fbiplobsd%2FOneClickRun\" alt=\"Hits\" align=\"right\"></center>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "BPOvlZP78NuJ"
      },
      "source": [
        "___Jellyfin Preview___ <img src=\"https://media.giphy.com/media/3kIHVWVw2rDIfJyiN1/giphy.gif\" height=15px>\n",
        "![preview](https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/preview.gif)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rnFLGfbepLQz"
      },
      "source": [
        "___aria2 Rpc Config Setup___ <img src=\"https://media.giphy.com/media/3kIHVWVw2rDIfJyiN1/giphy.gif\" height=15px>\n",
        "![preview](https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/aria2RpcConfigSetup.gif)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lb45olSEmSNl"
      },
      "source": [
        "___SSH Preview___ <img src=\"https://media.giphy.com/media/3kIHVWVw2rDIfJyiN1/giphy.gif\" height=15px>\n",
        "![preview](https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/sshPreview.gif)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "sGFA1R3iYIqK"
      },
      "source": [
        "___Rclone config create___ <img src=\"https://media.giphy.com/media/3kIHVWVw2rDIfJyiN1/giphy.gif\" height=15px>\n",
        "![preview](https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/rclone_config_create.gif)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EkjL0r6ouLD4"
      },
      "source": [
        "___L3MON DEMO___ <img src=\"https://media.giphy.com/media/3kIHVWVw2rDIfJyiN1/giphy.gif\" height=15px>\n",
        "![preview](https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/L3MON_DEMO.gif)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "KlZ8r1fJ_scW"
      },
      "source": [
        "___NoMachine___ <img src=\"https://media.giphy.com/media/3kIHVWVw2rDIfJyiN1/giphy.gif\" height=15px>\n",
        "![preview](https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/NoMachine.gif)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yvcQmeGIfXGI"
      },
      "source": [
        "#`mountUmount(`<font size=\"3px\" color=\"#01c968\">`Gdrive`</font>`)`\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tPuLCnbGFmxo",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Google_Drive_logo.png/600px-Google_Drive_logo.png' height=\"50\" alt=\"Gdrive-logo\"/></center>\n",
        "#@markdown <center><h3>Mount Gdrive to /content/drive</h3></center><br>\n",
        "MODE = \"MOUNT\" #@param [\"MOUNT\", \"UNMOUNT\"]\n",
        "#Mount your Gdrive! \n",
        "from google.colab import drive\n",
        "drive.mount._DEBUG = False\n",
        "if MODE == \"MOUNT\":\n",
        "  drive.mount('/content/drive', force_remount=True)\n",
        "elif MODE == \"UNMOUNT\":\n",
        "  try:\n",
        "    drive.flush_and_unmount()\n",
        "  except ValueError:\n",
        "    pass\n",
        "  get_ipython().system_raw(\"rm -rf /root/.config/Google/DriveFS\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NuyWhC0U_Dzv"
      },
      "source": [
        "#`useFulTools(`<font size=\"3px\" color=\"#a05fc3\">`Jellyfin` </font> , <font size=\"3px\" color=\"#ff55cc\">`V2Ray` </font> , <font size=\"3px\" color=\"#ffce42\">`pyLoad` </font> , <font size=\"3px\" color=\"#2ebd59\">`spotify-downloader` </font> , <font size=\"3px\" color=\"#21b5f7\">`aria2Rpc` </font> , <font size=\"3px\" color=\"#85ffbb\"> `aria2Cli`</font> , <font size=\"3px\" color=\"#88caf0\"> `zip-tar-rar`</font>`)`\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "znqEQoWfTjGx"
      },
      "source": [
        "## <img src='https://jellyfin.org/favicon.ico' height=\"25\" alt=\"V2Ray\" /> __Jellyfin__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_ljeW5fKB0fx",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img alt=\"\" src=\"data:image/png;base64,[encoded data, 70464 characters]\" height=\"200\" alt=\"jellyfin\"/></center>\n",
        "#@markdown <center><h3>Jellyfin<br />The Free Software Media System.</h3></center><br>\n",
        "import os, zipfile, tarfile, requests, re\n",
        "import urllib.request\n",
        "from IPython.display import clear_output, display\n",
        "from ipywidgets import Dropdown, Select\n",
        "from subprocess import Popen\n",
        "import xml.etree.ElementTree as ET\n",
        "\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "LATEST_VERSION = False  # @param {type:\"boolean\"}\n",
        "CUSTOM_VERSION = \"10.7.6\"  # @param {type:\"string\"} \n",
        "#@markdown <small>&emsp;Version are available on https://repo.jellyfin.org/archive/linux/stable/</small>\n",
        "REGION = \"SA\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "#@markdown Default <br>&emsp;username : admin\n",
        "\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    CWD,\n",
        "    textAn\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs('tools/jellyfin/temp', exist_ok=True)\n",
        "os.makedirs('tools/jellyfin/transcodes', exist_ok=True)\n",
        "os.makedirs('downloads', exist_ok=True)\n",
        "\n",
        "def ff_loader(name):\n",
        "  import requests\n",
        "\n",
        "  url = requests.get(\n",
        "    \"https://ffbinaries.com/api/v1/version/latest\"\n",
        "    ).json()['bin']['linux-64'][name]\n",
        "  urllib.request.urlretrieve(url, f'tools/jellyfin/L{name}.zip')\n",
        "\n",
        "  with zipfile.ZipFile(f'tools/jellyfin/L{name}.zip', 'r') as zip_ref:\n",
        "      zip_ref.extractall('tools/jellyfin/')\n",
        "  os.remove(f\"tools/jellyfin/L{name}.zip\")\n",
        "  runSh(\"rm -rf tools/jellyfin/__MACOSX\")\n",
        "  os.replace(f\"tools/jellyfin/{name}\", f\"/usr/bin/{name}\")\n",
        "  os.chmod(f\"/usr/bin/{name}\", 0o755)\n",
        "\n",
        "def customVersionSelect():\n",
        "  allVersionPage = requests.get(\"https://repo.jellyfin.org/archive/linux/stable/\").text\n",
        "  allVersinoTags = re.findall(r'\">(\\d+\\.\\d+\\.\\d+)', allVersionPage, re.M)\n",
        "  option_list = sorted(allVersinoTags, reverse=True)\n",
        "  dropdown = Select(description=\"Choose one:\", options=option_list)\n",
        "  dropdown.observe(main, names='value')\n",
        "  display(dropdown)\n",
        "\n",
        "def startService():\n",
        "  # Starting jellyfin\n",
        "  if not findProcess(\"jellyfin\", \"--ffmpeg\"):\n",
        "    CM = r\"tools/jellyfin/jellyfin/jellyfin --service \" \\\n",
        "    f\"-C tools/jellyfin -d {CWD}/tools/jellyfin\"\n",
        "    Popen(CM.split())\n",
        "\n",
        "\n",
        "  # START_SERVER\n",
        "  # Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "  Server = PortForward_wrapper(\n",
        "      PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['jellyfin', 8096, 'http']],\n",
        "      REGION.lower(), [f\"{HOME}/.ngrok2/jellyfin.yml\", 7097]\n",
        "  ).start('jellyfin', displayB=True)\n",
        "\n",
        "def main(version=None):\n",
        "\n",
        "  # JellyfinMain\n",
        "  if LATEST_VERSION:\n",
        "    serverUrl = \"https://repo.jellyfin.org/releases/server/linux/stable/combined/\"\n",
        "  elif CUSTOM_VERSION:\n",
        "    serverUrl = f\"https://repo.jellyfin.org/archive/linux/stable/{CUSTOM_VERSION}/combined/\"\n",
        "  else:\n",
        "    serverUrl = f\"https://repo.jellyfin.org/archive/linux/stable/{version.new}/combined/\"\n",
        "\n",
        "  server = requests.get(serverUrl).text\n",
        "  server_file = re.search(r'f=\\\"(.+)\\\">jellyfin_(.+)\\.tar\\.gz<',\n",
        "                              server, re.MULTILINE)\n",
        "  server_file_url = server_file.group(1)\n",
        "  versionTag = server_file.group(2)\n",
        "\n",
        "  clear_output(True)\n",
        "  loadingAn()\n",
        "  textAn(f\"Installing v{versionTag} ...\", ty='twg')\n",
        "  \n",
        "  outputFile = 'tools/jellyfin/temp/jellyfin.tar.gz'\n",
        "  urllib.request.urlretrieve(serverUrl+server_file_url, outputFile)\n",
        "  with tarfile.open(outputFile, 'r:gz') as tar_ref:\n",
        "      tar_ref.extractall('tools/jellyfin')\n",
        "  os.renames(f'tools/jellyfin/jellyfin_{versionTag}',\n",
        "            'tools/jellyfin/jellyfin')\n",
        "  os.remove(outputFile)\n",
        "\n",
        "  # Default config data\n",
        "  defaultConfig = \"https://raw.githubusercontent.com/biplobsd\" \\\n",
        "  \"/OneClickRun/master/res/appdata/jellyfin/data.tar.gz\"\n",
        "  outputFile = 'tools/jellyfin/temp/data.tar.gz'\n",
        "  urllib.request.urlretrieve(defaultConfig, outputFile)\n",
        "  with tarfile.open(outputFile, 'r:gz') as tar_ref:\n",
        "      tar_ref.extractall('tools/jellyfin')\n",
        "  os.remove(outputFile)\n",
        "  \n",
        "  # https://github.com/rokibulislaam/colab-ffmpeg-cuda\n",
        "  ## with GPU \n",
        "  if os.system(\"nvidia-smi --query-gpu=name --format=csv,noheader\")==0: \n",
        "    encoConfigP = 'tools/jellyfin/config/encoding.xml'\n",
        "    mytree = ET.parse(encoConfigP) \n",
        "    myroot = mytree.getroot() \n",
        "\n",
        "    def addnew(name, value):\n",
        "      ET.SubElement(myroot, name).text = value\n",
        "\n",
        "    addnew('TranscodingTempPath', '/content/tools/jellyfin/transcodes')\n",
        "    addnew('HardwareAccelerationType', 'nvenc')\n",
        "    addnew('DeinterlaceMethod', 'yadif')\n",
        "    addnew('EnableDecodingColorDepth10Hevc', 'true')\n",
        "    addnew('EnableDecodingColorDepth10Vp9', 'true')\n",
        "    addnew('EnableDecodingColorDepth10Vp9', 'true')\n",
        "    addnew('EncoderPreset', 'slower')\n",
        "    addnew('EncodingThreadCount', '0')\n",
        "\n",
        "    for tagname in myroot.iter('HardwareDecodingCodecs'):\n",
        "      ET.SubElement(tagname, 'string').text = 'hevc'\n",
        "      ET.SubElement(tagname, 'string').text = 'mpeg2video'\n",
        "      ET.SubElement(tagname, 'string').text = 'mpeg4'\n",
        "      ET.SubElement(tagname, 'string').text = 'vp8'\n",
        "      ET.SubElement(tagname, 'string').text = 'vp9'\n",
        "\n",
        "    mytree.write(encoConfigP) \n",
        "\n",
        "    runSh(\n",
        "        \"git clone --depth 1 --branch main https://github.com/rokibulislaam/colab-ffmpeg-cuda.git tools/colab-ffmpeg-cuda\")\n",
        "    runSh(\"cp -r tools/colab-ffmpeg-cuda/bin/. /usr/bin/\")\n",
        "    ffmpegPath = '/usr/bin/ffmpeg'\n",
        "  else:\n",
        "    ## without GPU\n",
        "    # ffmpeg\n",
        "    ff_loader('ffmpeg')\n",
        "\n",
        "    # ffprobe\n",
        "    ff_loader('ffprobe')\n",
        "    \n",
        "    ffmpegPath = '/usr/bin/ffmpeg'\n",
        "  \n",
        "  startService()\n",
        "\n",
        "if not os.path.exists(\"tools/jellyfin/jellyfin/jellyfin\"):\n",
        "  if LATEST_VERSION or CUSTOM_VERSION:\n",
        "    main()\n",
        "  else:\n",
        "    customVersionSelect()\n",
        "else:\n",
        "  startService()\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "AOrO7nJ_7wjh"
      },
      "source": [
        "## <img src='https://www.v2ray.com/resources/v2ray_1024.png' height=\"25\" alt=\"V2Ray\" /> __V2Ray__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "maDRAy2D7wjk",
        "cellView": "form"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "#@markdown <br><center><img src='https://www.v2ray.com/resources/v2ray_1024.png' height=\"100\" alt=\"V2Ray\"/></center>\n",
        "#@markdown <center><h3>V2Ray<br />An free and open-source proxy server</h3></center><br>\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"US\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "ID=\"\"  # @param {type:\"string\"}\n",
        "DEFAULT_SET = True  # @param {type:\"boolean\"}\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "# ================================================================ #\n",
        " \n",
        "import json\n",
        "import base64\n",
        "import uuid\n",
        "import os\n",
        "import urllib.request\n",
        "import re\n",
        "from IPython.display import HTML, clear_output\n",
        "from subprocess import Popen\n",
        "import pandas as pd\n",
        "import requests\n",
        " \n",
        "HOME = os.path.expanduser(\"~\")\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        " \n",
        "from ocr import PortForward_wrapper, findPackageR, textAn\n",
        " \n",
        "def show_qr(text, v=True):\n",
        "  try:\n",
        "    from MyQR import myqr\n",
        "  except:\n",
        "    Popen(\"pip install myqr\".split()).wait()\n",
        "  Popen([\"myqr\",text]+\"--version 5 --level H -n qrcode.png -d /tmp\".split()).wait()\n",
        "  if v:\n",
        "    from PIL import Image\n",
        "    im = Image.open(\"/tmp/qrcode.png\")\n",
        "    os.remove(\"/tmp/qrcode.png\")\n",
        "    im.show()\n",
        "    import matplotlib.pyplot as plt\n",
        "    plt.figure(figsize=(5,5))\n",
        "    plt.imshow(im)\n",
        "    plt.axis('off')\n",
        "    plt.show()\n",
        "  else:\n",
        "    with open(\"/tmp/qrcode.png\", \"rb\") as imageFile:\n",
        "      imgb64 = base64.b64encode(imageFile.read())\n",
        "    os.remove(\"/tmp/qrcode.png\")\n",
        "    return imgb64\n",
        "\n",
        "def v2ray(id=None,port=9999):\n",
        "  \n",
        "  found = findPackageR('v2fly/v2ray-core', 'v2ray-linux-64.zip', all_=True)\n",
        "  downUrl = found['assets']['browser_download_url']\n",
        "  print(f\"Installing v2ray {found['tag_name']} ...\")\n",
        "  if not os.path.exists(\"/v2raybin\"):\n",
        "    os.system(f'mkdir -m 777 /v2raybin  &&  cd /v2raybin  && curl -L -H \"Cache-Control: no-cache\" -o v2ray.zip {downUrl}  && unzip v2ray.zip  && chmod +x /v2raybin/v2ray  && rm -rf v2ray.zip  && chgrp -R 0 /v2raybin  && chmod -R g+rwX /v2raybin')\n",
        "  CONFIG_JSON1=\"{\\\"log\\\":{\\\"access\\\":\\\"\\\",\\\"error\\\":\\\"\\\",\\\"loglevel\\\":\\\"warning\\\"},\\\"inbound\\\":{\\\"protocol\\\":\\\"vmess\\\",\\\"port\\\":\"\n",
        "  CONFIG_JSON2=\",\\\"settings\\\":{\\\"clients\\\":[{\\\"id\\\":\\\"\"\n",
        "  CONFIG_JSON3=\"\\\",\\\"alterId\\\":64}]},\\\"streamSettings\\\":{\\\"network\\\":\\\"ws\\\"}},\\\"inboundDetour\\\":[],\\\"outbound\\\":{\\\"protocol\\\":\\\"freedom\\\",\\\"settings\\\":{}}}\"\n",
        "  with open(\"config.json\",\"w\") as f:\n",
        "    f.write(CONFIG_JSON1+str(port)+CONFIG_JSON2+id+CONFIG_JSON3)\n",
        "  return Popen(\"/v2raybin/v2ray\")\n",
        " \n",
        "port=9910\n",
        " \n",
        "if not ID:\n",
        "  ID=str(uuid.uuid4())\n",
        "print(\"Setting up v2ray server ... \")\n",
        "v2ray(ID,port)\n",
        "print(\"Setting up tunnel ... \")\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['v2ray', port, 'http']],\n",
        "    REGION.lower(), [f\"{HOME}/.ngrok2/V2ray.yml\", 8097]\n",
        ").start('v2ray', displayB=False)\n",
        " \n",
        "d=json.loads('{\"add\":\"{0}\",\"aid\":\"64\",\"host\":\"\",\"id\":\"{1}\",\"net\":\"ws\",\"path\":\"\",\"port\":\"80\",\"ps\":\"1\",\"tls\":\"\",\"type\":\"none\",\"v\":\"2\"}')\n",
        "d[\"add\"]=re.search(\"(?<=//).*?(/|$)\",Server[\"url\"]).group()\n",
        "d[\"id\"]=ID\n",
        "clear_output()\n",
        "# print(d)\n",
        "config=\"vmess://\"+base64.b64encode(json.dumps(d).encode()).decode(\"utf-8\")\n",
        "# print(config)\n",
        "imgb64 = show_qr(config, v=False).decode()\n",
        "df_marks = pd.Series(d).to_frame(\"V2Ray Config\")\n",
        "html = df_marks.to_html(classes=\"zui-table blueBG\")\n",
        "display(HTML(\"\"\"<style>@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200,900');  :root {   --text-color: hsla(210, 50%, 85%, 1);   --shadow-color: hsla(210, 40%, 52%, .4);   --btn-color: hsl(210, 80%, 42%);   --bg-color: #141218; }  * {   box-sizing: border-box; } button { position:relative; padding: 10px 20px;     border: none;   background: none;      font-family: \"Source Code Pro\";   font-weight: 900;font-size: 100%;     color: var(--text-color);      background-color: var(--btn-color);   box-shadow: var(--shadow-color) 2px 2px 22px;   border-radius: 4px;    z-index: 0;overflow: hidden; -webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;}  button:focus {   outline-color: transparent;   box-shadow: var(--btn-color) 2px 2px 22px; }  .right::after, button::after {   content: var(--content);   display: block;   position: absolute;   white-space: nowrap;   padding: 40px 40px;   pointer-events:none; }  button::after{   font-weight: 200;   top: -30px;   left: -20px; }   .right, .left {   position: absolute;   width: 100%;   height: 100%;   top: 0; } .right {   left: 66%; } .left {   right: 66%; } .right::after {   top: -30px;   left: calc(-66% - 20px);      background-color: var(--bg-color);   color:transparent;   transition: transform .4s ease-out;   transform: translate(0, -90%) rotate(0deg) }  button:hover .right::after {   transform: translate(0, -47%) rotate(0deg) }  button .right:hover::after {   transform: translate(0, -50%) rotate(-7deg) }  button .left:hover ~ .right::after {   transform: translate(0, -50%) rotate(7deg) }  /* bubbles */ button::before {   content: '';   pointer-events: none;   opacity: .6;   background:     radial-gradient(circle at 20% 35%,  transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 75% 44%, transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--text-color) 5px, var(--text-color) 6px, transparent 6px);    width: 100%;   height: 300%;   top: 0;   left: 0;   position: absolute;   animation: bubbles 5s linear infinite both; }  @keyframes bubbles {   from {     transform: translate();   }   to {     transform: translate(0, -66.666%);   } }.zui-table {border: solid 1px #DDEEEE;    border-collapse: collapse;    border-spacing: 0;    font: normal 13px;}.zui-table thead th {    background-color: #DDEFEF;    border: solid 1px #DDEEEE;    color: #0000009e;    padding: 10px;    text-align: left;}.zui-table tbody td {border: solid 1px #effff97a;color: #ffffffd1;    padding: 10px;}</style><center><button style=\"width: 60%\" onclick=\"copy_text_fun()\"><img style=\"width: 40%;\" src=\"data:image/png;base64, \"\"\"+imgb64+\"\"\"\"/><div style=\"text-align: -webkit-center;\">\"\"\"+html+\"\"\"</div><a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://bit.ly/34E09QG\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))\n",
        "display(HTML(\"\"\"<script type=\"text/javascript\">function copy_text_fun() {var copyText = document.getElementById(\"copy_txt\"); var input = document.createElement(\"textarea\");input.value = copyText.textContent;document.body.appendChild(input);input.select();document.execCommand(\"Copy\");input.remove();}</script><p hidden id=\"copy_txt\">\"\"\"+config+\"\"\"</p>\"\"\"))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "VDInERXVmnm8"
      },
      "source": [
        "## <img src='https://github.com/pyload/pyload-webui/raw/master/media/banner.png' height=\"60\" alt=\"pyLoad\" /> <font size=1px>___PyLoad___</font>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GgY-Xq0Jm0gc",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to START server</h3>\n",
        "#@markdown <br><center><img src='https://github.com/pyload/pyload-webui/raw/master/media/banner.png' height=\"100\" alt=\"pyLoad\"/></center>\n",
        "#@markdown <center><h3>pyLoad Webinterface<br />The free and open-source Download Manager written in pure Python</h3></center><br>\n",
        "import os, pathlib, zipfile, re, threading\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "Version = '1.3.0'\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"SA\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "#@markdown Default <br>&emsp;username : admin<br>&emsp;password : admin\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs('downloads', exist_ok=True)\n",
        "os.makedirs('tools/pyload', exist_ok=True)\n",
        "\n",
        "# Downloading latest version of pyload\n",
        "if not os.path.exists(\"tools/pyload/pyload-stable\"):\n",
        "  urlF = 'https://github.com/pyload/pyload/archive/stable.zip'\n",
        "  conf = 'https://raw.githubusercontent.com/biplobsd/' \\\n",
        "          'OneClickRun/master/res/appdata/pyload/pyload.conf'\n",
        "  db = 'https://github.com/biplobsd/OneClickRun/raw/master/' \\\n",
        "        'res/appdata/pyload/files.db'\n",
        "  urllib.request.urlretrieve(urlF, 'tools/pyload.zip')\n",
        "  urllib.request.urlretrieve(conf, 'tools/pyload/pyload.conf')\n",
        "  urllib.request.urlretrieve(db, 'tools/pyload/files.db')\n",
        "  with zipfile.ZipFile('tools/pyload.zip', 'r') as zip_ref:\n",
        "      zip_ref.extractall('tools/pyload')\n",
        "  try:\n",
        "    pathlib.Path('tools/pyload.zip').unlink()\n",
        "  except FileNotFoundError:\n",
        "    pass\n",
        "\n",
        "  # runSh(\"apt install -y python-pycurl python-qt4 tesseract-ocr libtesseract-dev\")\n",
        "  # runSh(\"pip2 install pycrypto pyOpenSSL Jinja2 tesseract tesseract-ocr\")\n",
        "\n",
        "  # Using Threading to install\n",
        "  threadRun = [\n",
        "    threading.Thread(target=runSh, args=(\"apt install -y python-pycurl python-qt4 tesseract-ocr libtesseract-dev\",)),\n",
        "    threading.Thread(target=runSh, args=(\"pip2 install pycrypto pyOpenSSL Jinja2 tesseract tesseract-ocr\",))\n",
        "  ]\n",
        "  for perTh in threadRun:perTh.start()\n",
        "  for perTh in threadRun:perTh.join()\n",
        "\n",
        "if not findProcess(\"python2.7\", \"pyLoadCore.py\"):\n",
        "  runCmd = \"python2.7 /content/tools/pyload/pyload-stable/pyLoadCore.py\" \\\n",
        "          \" --configdir=/content/tools/pyload\" \\\n",
        "          \" --no-remote\" \\\n",
        "          \" --daemon\"\n",
        "  runSh(runCmd, shell=True)\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['rcloneConfig', 53682, 'http'], \n",
        "                            ['pyload', 8000, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/rclonePyload.yml\", 4074]\n",
        ").start('pyload')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "PE5J1UDzQXSp"
      },
      "source": [
        "## <img src='https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/spotify-downloader.png' height=\"25\" alt=\"spotify-downloader\" /> ___spotify-downloader___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "v71nnHGOlaSb",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/spotify-downloader.png' height=\"100\" alt=\"spotify-downloader\"/></center>\n",
        "#@markdown <center><h3>spotify-downloader<br />Download Spotify playlists from YouTube with albumart and meta-tags</h3></center><br>\n",
        "\n",
        "import os, uuid, urllib.parse, re\n",
        "import ipywidgets as widgets\n",
        "\n",
        "from glob import glob\n",
        "from urllib.parse import urlparse, parse_qs\n",
        "from IPython.display import HTML, clear_output, YouTubeVideo\n",
        "from IPython.utils.io import ask_yes_no\n",
        "from google.colab import output, files\n",
        "\n",
        "\n",
        "os.makedirs('tools/spotify-downloader/', exist_ok=True)\n",
        "os.makedirs('downloads', exist_ok=True)\n",
        "LATEST_VERSION = False #@param {type:\"boolean\"}\n",
        "\n",
        "SET_VERSION = \"2.0.8\" #@param {type:\"string\"}\n",
        "#@markdown  <font size='2px'>`https://pypi.org/project/spotdl/#history`</font>\n",
        "# # Config files\n",
        "# data = \"\"\"spotify-downloader:\n",
        "#   avconv: false\n",
        "#   download-only-metadata: false\n",
        "#   dry-run: false\n",
        "#   file-format: '{artist} - {track_name}'\n",
        "#   folder: /home/user/Music\n",
        "#   input-ext: .m4a\n",
        "#   log-level: INFO\n",
        "#   manual: false\n",
        "#   music-videos-only: false\n",
        "#   no-fallback-metadata: false\n",
        "#   no-metadata: false\n",
        "#   no-spaces: false\n",
        "#   output-ext: .mp3\n",
        "#   overwrite: prompt\n",
        "#   search-format: '{artist} - {track_name} lyrics'\n",
        "#   skip: null\n",
        "#   spotify_client_id: 4fe3fecfe5334023a1472516cc99d805\n",
        "#   spotify_client_secret: 0f02b7c483c04257984695007a4a8d5c\n",
        "#   trim-silence: false\n",
        "#   write-successful: null\n",
        "#   write-to: null\n",
        "#   youtube-api-key: null\n",
        "# \"\"\"\n",
        "# with open('tools/spotify-downloader/config.yml', 'w') as wnow:\n",
        "#   wnow.write(data)\n",
        "\n",
        "Links = widgets.Textarea(placeholder='''Link list\n",
        "(one link per line)''')\n",
        "\n",
        "fileFormat = widgets.Text(\n",
        "    value='{artist} - {track_name}',\n",
        "    placeholder='File name format',\n",
        "    description=\"\"\"File Name : file format to save the downloaded track with, each\n",
        "                        tag is surrounded by curly braces. Possible formats:\n",
        "                        ['track_name', 'artist', 'album', 'album_artist',\n",
        "                        'genre', 'disc_number', 'duration', 'year',\n",
        "                        'original_date', 'track_number', 'total_tracks',\n",
        "                        'isrc']\"\"\",\n",
        "    disabled=False\n",
        ")\n",
        "\n",
        "searchFormat = widgets.Text(\n",
        "    value='{artist} - {track_name} lyrics',\n",
        "    placeholder='Search format',\n",
        "    description=\"\"\"Search Format : search format to search for on YouTube, each tag is\n",
        "                        surrounded by curly braces. Possible formats:\n",
        "                        ['track_name', 'artist', 'album', 'album_artist',\n",
        "                        'genre', 'disc_number', 'duration', 'year',\n",
        "                        'original_date', 'track_number', 'total_tracks',\n",
        "                        'isrc']\"\"\",\n",
        "    disabled=False\n",
        ")\n",
        "\n",
        "tab = widgets.Tab()\n",
        "\n",
        "LinksType = widgets.RadioButtons(\n",
        "    options=['Songs', 'Playlist', 'Album', 'Username', 'Artist'],\n",
        "    value='Songs',\n",
        "    layout={'width': 'max-content'},\n",
        "    description='Links type:',\n",
        "    disabled=False,\n",
        ")\n",
        "\n",
        "SavePathYT = widgets.Dropdown(options=[\"/content/downloads\", \"/content\"])\n",
        "\n",
        "Extension = widgets.Select(options=[\"flac\", \"mp3\", \"m4a\"], value=\"mp3\")\n",
        "\n",
        "TrimSilence = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='Trim silence',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='remove silence from the start of the audio',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "writeM3u = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='Write .m3u playlist',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='''generate an .m3u playlist file with youtube links\n",
        "               given a text file containing tracks''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "noMeta = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='No metadata',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='do not embed metadata in tracks',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "noEnco = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='No Encoding',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='do not encode media using FFmpeg',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "overwrite = widgets.Dropdown(\n",
        "    disabled=False,\n",
        "    options=['prompt', 'force', 'skip'],\n",
        "    value='skip',\n",
        "    description='Overwrite:',\n",
        ")\n",
        "\n",
        "quality = widgets.Dropdown(\n",
        "    disabled=False,\n",
        "    options=['worst', 'best'],\n",
        "    value='best',\n",
        "    description='Quality:',\n",
        ")\n",
        "\n",
        "inputExt = widgets.Dropdown(\n",
        "    disabled=False,\n",
        "    options=['automatic', 'm4a', 'opus'],\n",
        "    value='automatic',\n",
        "    description='Input format:',\n",
        ")\n",
        "\n",
        "logLevel = widgets.Dropdown(\n",
        "    disabled=False,\n",
        "    options=['INFO', 'WARNING', 'ERROR', 'DEBUG'],\n",
        "    value='INFO',\n",
        "    description='Log level:',\n",
        ")\n",
        "\n",
        "nf = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='No fallback metadata',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='''do not use YouTube as fallback for metadata if track\n",
        "                        not found on Spotify''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "dryRun = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='Dry run',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip=''' show only track title and YouTube URL, and then skip\n",
        "                        to the next track (if any)''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "MusicVidOnly = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='Music Videos Only',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='''search only for music videos on Youtube (works only\n",
        "                        when YouTube API key is set''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "NoSpaces = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='No Spaces',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='''replace spaces with underscores in file names''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "manual = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='manually',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='''choose the track to download manually from a list of\n",
        "                        matching tracks''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "nr = widgets.ToggleButton(\n",
        "    value=False,\n",
        "    description='Keep original',\n",
        "    disabled=False,\n",
        "    button_style='',\n",
        "    tooltip='''do not remove the original file after conversion''',\n",
        "    icon='check'\n",
        ")\n",
        "\n",
        "ExtraArg = widgets.Text(placeholder=\"Extra Arguments\")\n",
        "\n",
        "class MakeButton(object):\n",
        "  def __init__(self, title, callback, style):\n",
        "    self._title = title\n",
        "    self._callback = callback\n",
        "    self._style = style\n",
        "  def _repr_html_(self):\n",
        "    callback_id = 'button-' + str(uuid.uuid4())\n",
        "    output.register_callback(callback_id, self._callback)\n",
        "    if self._style != \"\":\n",
        "      style_html = \"p-Widget jupyter-widgets jupyter-button widget-button mod-\" + self._style\n",
        "    else:\n",
        "      style_html = \"p-Widget jupyter-widgets jupyter-button widget-button\"\n",
        "    template = \"\"\"<button class=\"{style_html}\" id=\"{callback_id}\">{title}</button>\n",
        "        <script>\n",
        "          document.querySelector(\"#{callback_id}\").onclick = (e) => {{\n",
        "            google.colab.kernel.invokeFunction('{callback_id}', [], {{}})\n",
        "            e.preventDefault();\n",
        "          }};\n",
        "        </script>\"\"\"\n",
        "    html = template.format(title=self._title, callback_id=callback_id, style_html=style_html)\n",
        "    return html\n",
        "  \n",
        "def MakeLabel(description, button_style):\n",
        "  return widgets.Button(description=description, disabled=True, button_style=button_style)\n",
        "\n",
        "def RefreshPathYT():\n",
        "  if os.path.exists(\"/content/drive/\"):\n",
        "    if os.path.exists(\"/content/drive/Shared drives/\"):\n",
        "      SavePathYT.options = [\"/content\", \"/content/downloads\", \"/content/drive/My Drive\"] + glob(\"/content/drive/My Drive/*/\") + glob(\"/content/drive/Shared drives/*/\")\n",
        "    else:\n",
        "      SavePathYT.options = [\"/content\", \"/content/downloads\", \"/content/drive/My Drive\"] + glob(\"/content/drive/My Drive/*/\")\n",
        "  else:\n",
        "    SavePathYT.options = [\"/content/downloads\", \"/content\"]\n",
        "\n",
        "\n",
        "def ShowYT():\n",
        "  clear_output(wait=True)\n",
        "  RefreshPathYT()\n",
        "  mainTab = widgets.Box([\n",
        "                        widgets.HBox([widgets.VBox([\n",
        "                                      widgets.HTML(\"<b style=\\\"color:#888888;\\\">Link:</b>\"), Links,\n",
        "                                      LinksType, searchFormat, fileFormat, \n",
        "                                      widgets.HBox([TrimSilence, writeM3u, noMeta]),\n",
        "                                      widgets.HBox([nf, dryRun, MusicVidOnly]),\n",
        "                                      widgets.HBox([NoSpaces, manual, nr]),\n",
        "                                      widgets.HBox([noEnco])\n",
        "                                      ]),\n",
        "                        widgets.VBox([\n",
        "                                      widgets.HTML(\"<b style=\\\"color:#888888;\\\">Extension:</b>\"), \n",
        "                                      Extension,\n",
        "                                      widgets.HTML(\"<b style=\\\"color:#888888;\\\">Extra Arguments:</b>\"), \n",
        "                                      ExtraArg, overwrite, quality, inputExt, \n",
        "                                      logLevel])\n",
        "                        ])])\n",
        "  \n",
        "  tab.children = [mainTab]\n",
        "  tab.set_title(0, 'spotify-downloader')\n",
        "  display(HTML(\"<style>widget-tab-bar {display: none;}</style>\"))\n",
        "  display(tab)\n",
        "  display(HTML(\"<h4 style=\\\"color:#888888;\\\">Save Location:</h4>\"), SavePathYT, MakeButton(\"Refresh\", RefreshPathYT, \"\"))\n",
        "  if not os.path.exists(\"/content/drive/\"):\n",
        "    display(HTML(\"*If you want to save in Google Drive please run the cell below.\"))\n",
        "  display(HTML(\"<br>\"), MakeButton(\"Download\", DownloadYT, \"info\"))\n",
        "\n",
        "def DownloadYT():\n",
        "  if Links.value.strip():\n",
        "    Count = 0\n",
        "    Total = str(len(Links.value.splitlines()))\n",
        "    \n",
        "    if writeM3u.value:\n",
        "      M3u = '--write-m3u'\n",
        "    else:\n",
        "      M3u = ''\n",
        "    \n",
        "    if TrimSilence.value:\n",
        "      trmS = '--trim-silence'\n",
        "    else:\n",
        "      trmS = ''\n",
        "    \n",
        "    if noMeta.value:\n",
        "      noM = '--no-metadata'\n",
        "    else:\n",
        "      noM = ''\n",
        "    \n",
        "    if noEnco.value:\n",
        "      noE = '--no-encode'\n",
        "    else:\n",
        "      noE = ''\n",
        "\n",
        "    if not overwrite.disabled:\n",
        "      oW = f'--overwrite {overwrite.value}'\n",
        "    else:\n",
        "      oW = ''\n",
        "\n",
        "    if not quality.disabled:\n",
        "      qL = f'--quality {quality.value}'\n",
        "    else:\n",
        "      qL = ''\n",
        "    \n",
        "    if not inputExt.disabled:\n",
        "      iE = f'--input-ext {inputExt.value}'\n",
        "    else:\n",
        "      iE = ''\n",
        "\n",
        "    if not logLevel.disabled:\n",
        "      lL = f'--log-level {logLevel.value}'\n",
        "    else:\n",
        "      lL = ''\n",
        "\n",
        "    if nf.value:\n",
        "      nfv = '--no-fallback-metadata'\n",
        "    else:\n",
        "      nfv = ''\n",
        "    \n",
        "    if dryRun.value:\n",
        "      drR = '--dry-run'\n",
        "    else:\n",
        "      drR = ''\n",
        "    \n",
        "    if MusicVidOnly.value:\n",
        "      MsV = '--music-videos-only'\n",
        "    else:\n",
        "      MsV = ''\n",
        "    \n",
        "    if NoSpaces.value:\n",
        "      NoS = '--no-spaces'\n",
        "    else:\n",
        "      NoS = ''\n",
        "    \n",
        "    if manual.value:\n",
        "      mal = '--manual'\n",
        "    else:\n",
        "      mal = ''\n",
        "    \n",
        "    if nr.value:\n",
        "      nro = '--no-remove-original' \n",
        "    else:\n",
        "      nro = ''\n",
        "    \n",
        "    if not searchFormat.value == '{artist} - {track_name} lyrics':\n",
        "      seFor = f'--search-format \"{searchFormat.value}\"'\n",
        "    else:\n",
        "      seFor = ''\n",
        "    \n",
        "    if not fileFormat.value == '{artist} - {track_name}':\n",
        "      fiFor = f'--file-format \"{fileFormat.value}\"'\n",
        "    else:\n",
        "      fiFor = ''\n",
        "    \n",
        "    if not LinksType.value == 'Songs':\n",
        "      with open('tools/spotify-downloader/finish.txt', 'a+') as master:\n",
        "        for Link in Links.value.splitlines():\n",
        "          if LinksType.value == 'Playlist':\n",
        "            outFileName = !spotdl --playlist $Link\n",
        "          elif LinksType.value == 'Album':\n",
        "            outFileName = !spotdl --album $Link\n",
        "          elif LinksType.value == 'Username':\n",
        "            outFileName = !spotdl -u $Link\n",
        "          elif LinksType.value == 'Artist':\n",
        "            outFileName = !spotdl --all-albums $Link\n",
        "          filename = re.search(r\"to\\s(.+\\.txt)\", outFileName[-1]).group(1)\n",
        "          with open(filename, 'r') as r:\n",
        "            master.write(r.read())\n",
        "    else:\n",
        "      for Link in Links.value.splitlines():\n",
        "        with open('tools/spotify-downloader/finish.txt', 'w') as master:\n",
        "          master.write(Link)\n",
        "    # Extra Arguments\n",
        "    \n",
        "    extraargC = ExtraArg.value\n",
        "    cmd = r\"spotdl -l 'tools/spotify-downloader/finish.txt' \" \\\n",
        "      fr\"-f '{SavePathYT.value}' \" \\\n",
        "      fr\"-o {Extension.value} \" \\\n",
        "      f\"{seFor} {fiFor} \" \\\n",
        "      f\"{M3u} {trmS} {oW} {noM} {noE} {nfv} {drR} {MsV} {NoS} {mal} {nro}\" \\\n",
        "      f\"{qL} {iE} {lL}\" \n",
        "    !$cmd\n",
        "    ShowYT()\n",
        "\n",
        "if not os.path.isfile(\"/usr/local/bin/spotdl\"):\n",
        "  get_ipython().system_raw(f\"pip3 install spotdl{'=='+SET_VERSION if LATEST_VERSION else ''} && apt -y install ffmpeg\")\n",
        "\n",
        "ShowYT()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fJ7W2Z0gcYa5"
      },
      "source": [
        "## <img src='data:image/png;base64,[encoded data, 74472 characters]' height=\"60\" alt=\"aria2\" /><font size=1px>___aria2___</font>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yN2xLpinUbl6",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to START server</h3>\n",
        "#@markdown <br><center><img src='data:image/png;base64,[encoded data, 74472 characters]' height=\"200\" alt=\"aria2\"/></center>\n",
        "#@markdown <center><h3>aria2<br />The next generation download utility.</h3></center><br>\n",
        "import os, pathlib, zipfile, re\n",
        "import urllib.request, requests\n",
        "from IPython.display import HTML, clear_output\n",
        "from urllib.parse import urlparse\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "REGION = \"JP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "# Aria2 Service\n",
        "Aria2_rpc = True  # @param {type:\"boolean\"}\n",
        "Ariang_WEBUI = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "# OUTPUT_DIR = \"\"  # @param {type:\"string\"}\n",
        "PORT = 8221\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    CWD,\n",
        "    displayUrl,\n",
        "    findProcess,\n",
        "    findPackageR\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "# Ariang SETUP\n",
        "runSh('apt install -y aria2')\n",
        "pathlib.Path('ariang').mkdir(mode=0o777, exist_ok=True)\n",
        "pathlib.Path('downloads').mkdir(mode=0o777, exist_ok=True)\n",
        "\n",
        "# github latest releases tag define\n",
        "def latestTag(link):\n",
        "  import re\n",
        "  from urllib.request import urlopen\n",
        "  htmlF = urlopen(link+\"/releases/latest\").read().decode('UTF-8')\n",
        "  return re.findall(r'.+\\/tag\\/([.0-9A-Za-z]+)\".+/', htmlF)[0]\n",
        "\n",
        "# Downloading latest version of ariang\n",
        "if not os.path.exists(\"ariang/index.html\"):\n",
        "  # BASE_URL = r\"https://github.com/mayswind/AriaNg\"\n",
        "  # LATEST_TAG = latestTag(BASE_URL)\n",
        "  # urlF = f'{BASE_URL}/releases/download/{LATEST_TAG}/' \\\n",
        "  #             f'AriaNg-{LATEST_TAG}-AllInOne.zip'\n",
        "  urllib.request.urlretrieve(\n",
        "      findPackageR('mayswind/AriaNg', 'AllInOne.zip'),\n",
        "      'ariang/new.zip')\n",
        "  with zipfile.ZipFile('ariang/new.zip', 'r') as zip_ref:\n",
        "      zip_ref.extractall('ariang')\n",
        "  try:\n",
        "    pathlib.Path('ariang/new.zip').unlink()\n",
        "  except FileNotFoundError:\n",
        "    pass\n",
        "\n",
        "# START_ARIANG_WEBUI_AND_ARIA2_RPC\n",
        "try:\n",
        "  if not OUTPUT_DIR:\n",
        "    OUTPUT_DIR = f\"downloads/\"\n",
        "  elif not os.path.exists(OUTPUT_DIR):\n",
        "    clear_output()\n",
        "    print(\"Error: Your set path not found! Create path!\")\n",
        "    exx()\n",
        "except:\n",
        "  OUTPUT_DIR = f\"{CWD}/downloads/\"\n",
        "if Aria2_rpc:\n",
        "  if not findProcess(\"aria2c\", \"--enable-rpc\"):\n",
        "    try:\n",
        "      trackers = requests.get(\n",
        "          \"https://trackerslist.com/best_aria2.txt\"\n",
        "      ).text\n",
        "      cmdC = r\"aria2c --enable-rpc --rpc-listen-port=6800 -D \" \\\n",
        "            fr\"-d {OUTPUT_DIR} \" \\\n",
        "            r\"-j 20 \" \\\n",
        "            r\"-c \" \\\n",
        "            fr\"--bt-tracker={trackers} \" \\\n",
        "            r\"--bt-request-peer-speed-limit=0 \" \\\n",
        "            r\"--bt-max-peers=0 \" \\\n",
        "            r\"--seed-ratio=0.0 \" \\\n",
        "            r\"--max-connection-per-server=10 \" \\\n",
        "            r\"--min-split-size=10M \" \\\n",
        "            r\"--follow-torrent=mem \" \\\n",
        "            r\"--disable-ipv6=true \" \\\n",
        "            r\"--user-agent=Transmission/2.77 --peer-agent=Transmission/2.77 \" \\\n",
        "            r\"--peer-id-prefix=-TR2770- \" \\\n",
        "            r\"--split=20 \" \\\n",
        "            r\" &\"\n",
        "      runSh(\n",
        "          cmdC,\n",
        "          shell=True\n",
        "      )\n",
        "    except:\n",
        "      print(\"aria2 rpc not enabling. Try again later!\")\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "if Aria2_rpc:\n",
        "  Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['Aria2_rpc', 6800, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/aria2.yml\", 5042]\n",
        ")\n",
        "  data = Server.start('Aria2_rpc', displayB=False)\n",
        "  Host = urlparse(data['url']).hostname\n",
        "  port = \"80\"\n",
        "  clear_output()\n",
        "if Ariang_WEBUI:\n",
        "  if Aria2_rpc:\n",
        "    filePath = 'ariang/index.html'\n",
        "    with open(filePath, 'r+') as f:\n",
        "      read_data = f.read()\n",
        "      f.seek(0)\n",
        "      f.truncate(0)\n",
        "      read_data = re.sub(r'(rpcHost:\"\\w+.\")|rpcHost:\"\"', \n",
        "                        f'rpcHost:\"{Host}\"', read_data)\n",
        "      read_data = re.sub(r'protocol:\"\\w+.\"', r'protocol:\"ws\"', read_data)\n",
        "      read_data = re.sub(r'rpcPort:\"\\d+.\"', f'rpcPort:\"{port}\"', read_data)\n",
        "      f.write(read_data)\n",
        "  try:\n",
        "    urllib.request.urlopen(f\"http://localhost:{PORT}\")\n",
        "  except:\n",
        "    runSh(f\"python3 -m http.server {PORT} &\", shell=True, cd=\"ariang/\")\n",
        "  \n",
        "  Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['Ariang', PORT, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/ariang.yml\", 5043]\n",
        ")\n",
        "  data2 = Server.start('Ariang', displayB=False)\n",
        "  data2['url'] = urlparse(data2['url'])._replace(scheme='http').geturl()\n",
        "  displayUrl(data2, pNamU='Ariang : ')\n",
        "\n",
        "if Aria2_rpc:\n",
        "  display(HTML(\"\"\"<style>@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200,900');  :root {   --text-color: hsla(210, 50%, 85%, 1);   --shadow-color: hsla(210, 40%, 52%, .4);   --btn-color: hsl(210, 80%, 42%);   --bg-color: #141218; }  * {   box-sizing: border-box; } button { position:relative; padding: 10px 20px;     border: none;   background: none;      font-family: \"Source Code Pro\";   font-weight: 900;font-size: 100%;     color: var(--text-color);      background-color: var(--btn-color);   box-shadow: var(--shadow-color) 2px 2px 22px;   border-radius: 4px;    z-index: 0;overflow: hidden; -webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;}  button:focus {   outline-color: transparent;   box-shadow: var(--btn-color) 2px 2px 22px; }  .right::after, button::after {   content: var(--content);   display: block;   position: absolute;   white-space: nowrap;   padding: 40px 40px;   pointer-events:none; }  button::after{   font-weight: 200;   top: -30px;   left: -20px; }   .right, .left {   position: absolute;   width: 100%;   height: 100%;   top: 0; } .right {   left: 66%; } .left {   right: 66%; } .right::after {   top: -30px;   left: calc(-66% - 20px);      background-color: var(--bg-color);   color:transparent;   transition: transform .4s ease-out;   transform: translate(0, -90%) rotate(0deg) }  button:hover .right::after {   transform: translate(0, -47%) rotate(0deg) }  button .right:hover::after {   transform: translate(0, -50%) rotate(-7deg) }  button .left:hover ~ .right::after {   transform: translate(0, -50%) rotate(7deg) }  /* bubbles */ button::before {   content: '';   pointer-events: none;   opacity: .6;   background:     radial-gradient(circle at 20% 35%,  transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 75% 44%, transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--text-color) 5px, var(--text-color) 6px, transparent 6px);    width: 100%;   height: 300%;   top: 0;   left: 0;   position: absolute;   animation: bubbles 5s linear infinite both; }  @keyframes bubbles {   from {     transform: translate();   }   to {     transform: translate(0, -66.666%);   } }.zui-table {    border: solid 1px #DDEEEE;    border-collapse: collapse;    border-spacing: 0;    font: normal 13px;}.zui-table thead th {    background-color: #DDEFEF;    border: solid 1px #DDEEEE;    color: #0000009e;    padding: 10px;    text-align: left;}.zui-table tbody td {border: solid 1px #effff97a;color: #ffffffd1;    padding: 10px;}</style><center><button><table class=\"zui-table blueBG\"><p>Aria2 rpc config<p><thead>        <tr>            <th>Protocol</th>            <th>Host</th>            <th>Port</th>        </tr>    </thead>    <tbody>        <tr>            <td>WebSocket</td><td>\"\"\"+Host+\"\"\"</td><td>\"\"\"+port+\"\"\"</td></tr></tbody></table><a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/aria2RpcConfigSetup.gif\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Ttv0CeCqLX0t"
      },
      "source": [
        "## <img src='https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/aria2cli.png' height=\"45\" alt=\"aira2\"/> <font size=1px >___Direct link downloader___</font>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ASgRAOtBnVDT"
      },
      "source": [
        "___Auto share link supported : Disk.yandex.com, Gdrive and youtube-dl all extractor...___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "plgToqkpLV5q",
        "cellView": "form"
      },
      "source": [
        "URL = \"\" #@param {type:\"string\"}\n",
        "#@markdown <center><h5>Default output path /content/downloads/</h5></center>\n",
        "OUTPUT_PATH = \"\" #@param {type:\"string\"}\n",
        "\n",
        "import pathlib\n",
        "import shutil\n",
        "import hashlib\n",
        "import requests\n",
        "from urllib.parse import urlparse\n",
        "from os import path, mkdir\n",
        "if not path.exists(\"/root/.ipython/ocr.py\"): \n",
        "    from subprocess import run\n",
        "    from shlex import split\n",
        "\n",
        "    shellCmd = \"wget -qq https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py \\\n",
        "                    -O /root/.ipython/ocr.py\"\n",
        "    run(split(shellCmd))\n",
        "from ocr import runSh\n",
        "\n",
        "def youtubedlInstall():\n",
        "  if not path.isfile(\"/usr/local/bin/youtube-dl\"):\n",
        "    cmdC = \"rm -rf /content/sample_data/ && \" \\\n",
        "            \" mkdir -p -m 666 /root/.YouTube-DL/ &&\" \\\n",
        "            \" apt-get install atomicparsley &&\" \\\n",
        "            \" curl -L https://yt-dl.org/downloads/latest/youtube-dl \" \\\n",
        "            \"-o /usr/local/bin/youtube-dl &&\" \\\n",
        "            \" chmod a+rx /usr/local/bin/youtube-dl\"\n",
        "    get_ipython().system_raw(cmdC)\n",
        "\n",
        "def aria2Install():\n",
        "  runSh('apt install -y aria2')\n",
        "\n",
        "def istmd(URL): \n",
        "  link = urlparse(URL)\n",
        "    \n",
        "  #YandexDisk\n",
        "  if link.netloc == \"yadi.sk\":\n",
        "    API_ENDPOINT = 'https://cloud-api.yandex.net/v1/disk/public/resources/' \\\n",
        "                    '?public_key={}&path=/{}&offset={}'\n",
        "    dry = False\n",
        "    def md5sum(file_path):\n",
        "        md5 = hashlib.md5()\n",
        "        with open(file_path, 'rb') as f:\n",
        "            for chunk in iter(lambda: f.read(128 * md5.block_size), b''):\n",
        "                md5.update(chunk)\n",
        "        return md5.hexdigest()\n",
        "\n",
        "\n",
        "    def check_and_download_file(target_path, url, size, checksum):\n",
        "        if path.isfile(target_path):\n",
        "            if size == path.getsize(target_path):\n",
        "                if checksum == md5sum(target_path):\n",
        "                    print('URL {}'.format(url))\n",
        "                    print('skipping correct {}'.format(target_path))\n",
        "                    return\n",
        "        if not dry:\n",
        "            print('URL {}'.format(url))\n",
        "            print('downloading {}'.format(target_path))\n",
        "            runSh(f'aria2c -x 16 -s 16 -k 1M -d {OUTPUT_PATH} {url}', output=True)\n",
        "            # r = requests.get(url, stream=True)\n",
        "            # with open(target_path, 'wb') as f:\n",
        "            #     shutil.copyfileobj(r.raw, f)\n",
        "\n",
        "\n",
        "    def download_path(target_path, public_key, source_path, offset=0):\n",
        "        print('getting \"{}\" at offset {}'.format(source_path, offset))\n",
        "        current_path = path.join(target_path, source_path)\n",
        "        pathlib.Path(current_path).mkdir(parents=True, exist_ok=True)\n",
        "        jsn = requests.get(API_ENDPOINT.format(public_key, source_path, offset)).json()\n",
        "        def try_as_file(j):\n",
        "            if 'file' in j:\n",
        "                file_save_path = path.join(current_path, j['name'])\n",
        "                check_and_download_file(file_save_path, j['file'], j['size'], j['md5'])\n",
        "                return True\n",
        "            return False\n",
        "\n",
        "        # first try to treat the actual json as a single file description\n",
        "        if try_as_file(jsn):\n",
        "            return\n",
        "\n",
        "        # otherwise treat it as a directory\n",
        "        emb = jsn['_embedded']\n",
        "        items = emb['items']\n",
        "        for i in items:\n",
        "            # each item can be a file...\n",
        "            if try_as_file(i):\n",
        "                continue\n",
        "            # ... or a directory\n",
        "            else:\n",
        "                subdir_path = path.join(source_path, i['name'])\n",
        "                download_path(target_path, public_key, subdir_path)\n",
        "\n",
        "        # check if current directory has more items\n",
        "        last = offset + emb['limit']\n",
        "        if last < emb['total']:\n",
        "            download_path(target_path, public_key, source_path, last)\n",
        "    download_path(OUTPUT_PATH, URL, '')\n",
        "    return False  \n",
        "  return URL\n",
        "\n",
        "if not OUTPUT_PATH:\n",
        "  OUTPUT_PATH = \"/content/downloads/\"\n",
        "  \n",
        "if not URL == \"\":\n",
        "  aria2Install()\n",
        "  youtubedlInstall()\n",
        "  try:\n",
        "    mkdir(\"downloads\")\n",
        "  except FileExistsError:\n",
        "    pass\n",
        "  url = istmd(URL)\n",
        "  if url != False:\n",
        "    print('URL {}'.format(URL))\n",
        "    cmdC = f'youtube-dl -o \"{OUTPUT_PATH}/%(title)s\" {URL} ' \\\n",
        "            '--external-downloader aria2c ' \\\n",
        "            '--external-downloader-args \"-x 16 -s 16 -k 1M\"'\n",
        "    runSh(cmdC, output=True)\n",
        "else:\n",
        "  print(\"Please input url\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "u5gtC3WRH5o-"
      },
      "source": [
        "##<img src='https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/zip.png' height=\"30\" alt=\"netdata\"> __Extracte/Archive Zip/Tar/Rar__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "k98WImeXH5pK"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "# @markdown #### ⬅️ Extract Files\n",
        "MODE = \"7Z\"  # @param [\"UNZIP\", \"UNTAR\", \"UNRAR\", \"7Z\"]\n",
        "PATH_TO_FILE = \"\"  # @param {type:\"string\"}\n",
        "extractPath = \"\"  # @param {type:\"string\"}\n",
        "ARCHIVE_PASSWORD = \"\" #@param {type:\"string\"}\n",
        "\n",
        "# ================================================================ #\n",
        "import os, urllib.request\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    checkAvailable,\n",
        ")\n",
        "\n",
        "def extractFiles():\n",
        "    global extractPath\n",
        "    if ARCHIVE_PASSWORD:\n",
        "      passADD = f'-P {ARCHIVE_PASSWORD}'\n",
        "    else:\n",
        "      passADD = ''\n",
        "    if not extractPath:\n",
        "      extractPath = \"/content/extract\"\n",
        "    os.makedirs(extractPath, exist_ok=True)\n",
        "    if MODE == \"UNZIP\":\n",
        "        runSh('unzip '+passADD+f' \"{PATH_TO_FILE}\" -d \"{extractPath}\"', output=True)\n",
        "    elif MODE == \"UNRAR\":\n",
        "        runSh(f'unrar x \"{PATH_TO_FILE}\" \"{extractPath}\" '+passADD+' -o+', output=True)\n",
        "    elif MODE == \"UNTAR\":\n",
        "        runSh(f'tar -C \"{extractPath}\" -xvf \"{PATH_TO_FILE}\"', output=True)\n",
        "    else:\n",
        "        runSh(f'7z x \"{PATH_TO_FILE}\" -o{extractPath} '+passADD, output=True)\n",
        "\n",
        "\n",
        "extractFiles()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "XO8dzdyyH5pT"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "# @markdown #### ⬅️ Archive Files\n",
        "MODE = \"ZIP\" #@param [\"ZIP\", \"TAR\", \"7Z\"]\n",
        "FILENAME = \"\"  # @param {type:\"string\"}\n",
        "PATH_TO_FILE = \"\"  # @param {type:\"string\"}\n",
        "ARCHIVE_PASSWORD = \"\" #@param {type:\"string\"}\n",
        "\n",
        "# option supports b k m g (bytes, kilobytes, megabytes, gigabytes)\n",
        "SPLIT = \"no\" #@param [\"1g\", \"2g\", \"3g\", \"4g\", \"5g\", \"no\"]\n",
        "\n",
        "\n",
        "compress = 4#@param  {type:\"slider\", min:0, max:9, step:0}\n",
        "#@markdown <font size=2%>Use this to path separate between to this character `|`. Ex `path/to /1 | path/to/2` </br>#Split only in zip mode.(Only for noobs)\n",
        "# ================================================================ #\n",
        "from pathlib import PurePosixPath\n",
        "\n",
        "pathList = PATH_TO_FILE.split('|')\n",
        "if MODE == \"ZIP\":\n",
        "    if not FILENAME:\n",
        "      FILENAME = \"/content/NEW_FILE.ZIP\"\n",
        "    if ARCHIVE_PASSWORD:\n",
        "      passADD = f'--password \"{ARCHIVE_PASSWORD}\"'\n",
        "    else:\n",
        "      passADD = ''\n",
        "    splitC = f\"-s {SPLIT}\" if not 'no' in SPLIT else \"\" \n",
        "    for part in pathList:\n",
        "      pathdic = PurePosixPath(part.strip())\n",
        "      parent = pathdic.parent\n",
        "      partName = pathdic.parts[-1]\n",
        "      cmd = f'cd \"{parent}\" && zip {passADD} -{compress} {splitC} -v -r -u \"{FILENAME}\" \"{partName}\"'\n",
        "      !$cmd\n",
        "elif MODE == \"TAR\":\n",
        "    if not FILENAME:\n",
        "      FILENAME = \"/content/NEW_FILE\"\n",
        "    cmd = f'GZIP=-{compress} tar -zcvf \"{FILENAME}.tar.gz\" {PATH_TO_FILE}'\n",
        "    !$cmd\n",
        "else:\n",
        "    if not FILENAME:\n",
        "        FILENAME = \"/content/NEW_FILE\"\n",
        "    for part in pathList:\n",
        "      pathdic = PurePosixPath(part.strip())\n",
        "      parent = pathdic.parent\n",
        "      partName = pathdic.parts[-1]\n",
        "      cmd = f'cd \"{parent}\" && 7z a -mx={compress} \"{FILENAME}.7z\" \"{partName}\"'\n",
        "      !$cmd\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9KIWnL2jCRB-"
      },
      "source": [
        "#`transferTools(`<font size=\"3x\" color=\"#ee0e15\">`Mega` </font>,<font size=\"3px\" color=\"#3f79ad\"> `Rclone`</font>,<font size=\"3px\" color=\"#32cd32\"> `Anonfiles`</font>,<font size=\"3px\" color=\"#32cd32\"> `Bayfiles`</font>` )`"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kSvUMUuTPX7r"
      },
      "source": [
        "##![alt text](https://mega.nz/favicon.ico?v=3) __TRANSFERE to MEGA__\n",
        "\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "q3uC2Lo5R6N9",
        "cellView": "form"
      },
      "source": [
        "# @markdown <center><h2>INPUT YOUR MEGA ID</h2></center><br>\n",
        "from functools import wraps\n",
        "import errno\n",
        "import os\n",
        "import signal\n",
        "import subprocess\n",
        "import shlex\n",
        "\n",
        "\n",
        "class TimeoutError(Exception):\n",
        "    pass\n",
        "\n",
        "\n",
        "def timeout(seconds=10, error_message=os.strerror(errno.ETIME)):\n",
        "    def decorator(func):\n",
        "        def _handle_timeout(signum, frame):\n",
        "            raise TimeoutError(error_message)\n",
        "\n",
        "        def wrapper(*args, **kwargs):\n",
        "            signal.signal(signal.SIGALRM, _handle_timeout)\n",
        "            signal.alarm(seconds)\n",
        "            try:\n",
        "                result = func(*args, **kwargs)\n",
        "            finally:\n",
        "                signal.alarm(0)\n",
        "            return result\n",
        "\n",
        "        return wraps(func)(wrapper)\n",
        "\n",
        "    return decorator\n",
        "\n",
        "\n",
        "if not os.path.exists(\"/root/.ipython/ocr.py\"):\n",
        "    from subprocess import run\n",
        "    from shlex import split\n",
        "\n",
        "    shellCmd = \"wget -qq https://raw.githubusercontent.com/biplobsd/OneClickRun/master/res/ocr.py \\\n",
        "                    -O /root/.ipython/ocr.py\"\n",
        "    run(split(shellCmd))\n",
        "from ocr import runSh\n",
        "\n",
        "@timeout(10)\n",
        "def runShT(args):\n",
        "    return runSh(args, output=True)\n",
        "\n",
        "\n",
        "# MEGAcmd installing\n",
        "if not os.path.exists(\"/usr/bin/mega-cmd\"):\n",
        "    print(\"Installing MEGA ...\")\n",
        "    runSh('sudo apt-get -y update')\n",
        "    runSh('sudo apt-get -y install libmms0 libc-ares2 libc6 libcrypto++6 libgcc1 libmediainfo0v5 libpcre3 libpcrecpp0v5 libssl1.1 libstdc++6 libzen0v5 zlib1g apt-transport-https')\n",
        "    runSh('sudo curl -sL -o /var/cache/apt/archives/MEGAcmd.deb https://mega.nz/linux/MEGAsync/Debian_9.0/amd64/megacmd-Debian_9.0_amd64.deb', output=True)\n",
        "    runSh('sudo dpkg -i /var/cache/apt/archives/MEGAcmd.deb', output=True)\n",
        "    print(\"MEGA is installed.\")\n",
        "else:\n",
        "    !pkill mega-cmd\n",
        "\n",
        "# INPUT YOUR MEGA ID\n",
        "\n",
        "USERNAME = \"\"  # @param {type:\"string\"}\n",
        "PASSWORD = \"\"  # @param {type:\"string\"}\n",
        "if not (USERNAME == \"\" or PASSWORD == \"\"):\n",
        "    try:\n",
        "        runShT(f\"mega-login {USERNAME} {PASSWORD}\")\n",
        "    except TimeoutError:\n",
        "        runSh('mega-whoami', output=True)\n",
        "else:\n",
        "    print(\"Please Input your Mega IDs.\")\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "E3N6hyM2I6hk",
        "cellView": "form"
      },
      "source": [
        "import time\n",
        "import subprocess\n",
        "import contextlib\n",
        "from IPython.display import clear_output\n",
        "# @markdown <br><center><img src='https://www.impactcomputing.co.uk/uploads/files/services/managed-office-365.svg' height=\"100\" alt=\"netdata\"/></center>\n",
        "# @markdown <center><h2>TRANSFERE NOW</h2></center><br>\n",
        "# TRANSFERE NOW\n",
        "\n",
        "PATH_TO_FILE = \"\"  # @param {type:\"string\"}\n",
        "# Unix, Windows and old Macintosh end-of-line\n",
        "newlines = ['\\n', '\\r\\n', '\\r']\n",
        "\n",
        "\n",
        "def unbuffered(proc, stream='stdout'):\n",
        "    stream = getattr(proc, stream)\n",
        "    with contextlib.closing(stream):\n",
        "        while True:\n",
        "            out = []\n",
        "            last = stream.read(1)\n",
        "            # Don't loop forever\n",
        "            if last == '' and proc.poll() is not None:\n",
        "                break\n",
        "            while last not in newlines:\n",
        "                # Don't loop forever\n",
        "                if last == '' and proc.poll() is not None:\n",
        "                    break\n",
        "                out.append(last)\n",
        "                last = stream.read(1)\n",
        "            out = ''.join(out)\n",
        "            yield out\n",
        "\n",
        "\n",
        "def transfare():\n",
        "    cmd = ['mega-put', PATH_TO_FILE, '/colab']\n",
        "    proc = subprocess.Popen(\n",
        "        cmd,\n",
        "        stdout=subprocess.PIPE,\n",
        "        stderr=subprocess.STDOUT,\n",
        "        # Make all end-of-lines '\\n'\n",
        "        universal_newlines=True,\n",
        "    )\n",
        "    for line in unbuffered(proc):\n",
        "        clear_output(wait=True)\n",
        "        print(line)\n",
        "\n",
        "try:\n",
        "    transfare()\n",
        "except FileNotFoundError:\n",
        "    print(\"Login your account!\")\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "XlDyLy_JZJ03",
        "cellView": "form"
      },
      "source": [
        "import sys, os, urllib.request\n",
        "import time\n",
        "import subprocess\n",
        "import contextlib\n",
        "from IPython.display import clear_output\n",
        "\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        ")\n",
        "#@title MEGA public link download\n",
        "URL = \"\" #@param {type:\"string\"}\n",
        "OUTPUT_PATH = \"\" #@param {type:\"string\"}\n",
        "if not OUTPUT_PATH:\n",
        "  os.makedirs(\"downloads\", exist_ok=True)\n",
        "  OUTPUT_PATH = \"downloads\"\n",
        "# MEGAcmd installing\n",
        "if not os.path.exists(\"/usr/bin/mega-cmd\"):\n",
        "    loadingAn()\n",
        "    print(\"Installing MEGA ...\")\n",
        "    runSh('sudo apt-get -y update')\n",
        "    runSh('sudo apt-get -y install libmms0 libc-ares2 libc6 libcrypto++6 libgcc1 libmediainfo0v5 libpcre3 libpcrecpp0v5 libssl1.1 libstdc++6 libzen0v5 zlib1g apt-transport-https')\n",
        "    runSh('sudo curl -sL -o /var/cache/apt/archives/MEGAcmd.deb https://mega.nz/linux/MEGAsync/Debian_9.0/amd64/megacmd-Debian_9.0_amd64.deb', output=True)\n",
        "    runSh('sudo dpkg -i /var/cache/apt/archives/MEGAcmd.deb', output=True)\n",
        "    print(\"MEGA is installed.\")\n",
        "    clear_output()\n",
        "\n",
        "# Unix, Windows and old Macintosh end-of-line\n",
        "newlines = ['\\n', '\\r\\n', '\\r']\n",
        "\n",
        "def unbuffered(proc, stream='stdout'):\n",
        "    stream = getattr(proc, stream)\n",
        "    with contextlib.closing(stream):\n",
        "        while True:\n",
        "            out = []\n",
        "            last = stream.read(1)\n",
        "            # Don't loop forever\n",
        "            if last == '' and proc.poll() is not None:\n",
        "                break\n",
        "            while last not in newlines:\n",
        "                # Don't loop forever\n",
        "                if last == '' and proc.poll() is not None:\n",
        "                    break\n",
        "                out.append(last)\n",
        "                last = stream.read(1)\n",
        "            out = ''.join(out)\n",
        "            yield out\n",
        "\n",
        "\n",
        "def transfare():\n",
        "    import codecs\n",
        "    decoder = codecs.getincrementaldecoder(\"UTF-8\")()\n",
        "    cmd = [\"mega-get\", URL, OUTPUT_PATH]\n",
        "    proc = subprocess.Popen(\n",
        "        cmd,\n",
        "        stdout=subprocess.PIPE,\n",
        "        stderr=subprocess.STDOUT,\n",
        "        # Make all end-of-lines '\\n'\n",
        "        universal_newlines=True,\n",
        "    )\n",
        "    for line in unbuffered(proc):\n",
        "        print(line)\n",
        "        \n",
        "\n",
        "\n",
        "transfare()\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yOnMe4O3jtXf"
      },
      "source": [
        "## <img src='https://biplobsd.github.io/RLabClone/img/title_rclonelab.svg' height=\"45\" alt=\"RcloneLab\"/> <font size=-4>___RcloneLab___</font>\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "9qOSyk-RCTCz",
        "cellView": "form"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "# @markdown #### ⬅️ Execute rClone\n",
        "\n",
        "Mode = \"Copy\"  # @param [\"Move\", \"Copy\", \"Sync\", \"Verify\", \"Dedupe\", \"Clean Empty Dirs\", \"Empty Trash\"]\n",
        "Source = \"\"  # @param {type:\"string\"}\n",
        "Destination = \"\"  # @param {type:\"string\"}\n",
        "Extra_Arguments = \"\"  # @param {type:\"string\"}\n",
        "COPY_SHARED_FILES = False  # @param{type: \"boolean\"}\n",
        "Compare = \"Size & Checksum\"\n",
        "TRANSFERS, CHECKERS = 20, 20\n",
        "THROTTLE_TPS = True\n",
        "BRIDGE_TRANSFER = False  # @param{type: \"boolean\"}\n",
        "FAST_LIST = False  # @param{type: \"boolean\"}\n",
        "OPTIMIZE_GDRIVE = True\n",
        "SIMPLE_LOG = True\n",
        "RECORD_LOGFILE = False  # @param{type: \"boolean\"}\n",
        "SKIP_NEWER_FILE = False\n",
        "SKIP_EXISTED = False\n",
        "SKIP_UPDATE_MODTIME = False\n",
        "ONE_FILE_SYSTEM = False\n",
        "LOG_LEVEL = \"DEBUG\"\n",
        "SYNC_MODE = \"Delete after transfering\"\n",
        "SYNC_TRACK_RENAME = True\n",
        "DEDUPE_MODE = \"Largest\"\n",
        "USE_TRASH = True\n",
        "DRY_RUN = False  # @param{type: \"boolean\"}\n",
        "# ================================================================ #\n",
        "from os import path as _p\n",
        "\n",
        "if not _p.exists(\"/root/.ipython/rlab_utils.py\"):\n",
        "    from shlex import split as _spl\n",
        "    from subprocess import run\n",
        "\n",
        "    shellCmd = \"wget -qq https://biplobsd.github.io/RLabClone/res/rlab_utils.py \\\n",
        "                    -O /root/.ipython/rlab_utils.py\"\n",
        "    run(_spl(shellCmd))\n",
        "\n",
        "from datetime import datetime as _dt\n",
        "from rlab_utils import (\n",
        "    displayOutput,\n",
        "    checkAvailable,\n",
        "    runSh,\n",
        "    prepareSession,\n",
        "    PATH_RClone_Config,\n",
        "    accessSettingFile,\n",
        "    memGiB,\n",
        ")\n",
        "\n",
        "\n",
        "def populateActionArg():\n",
        "    if Mode == \"Copy\":\n",
        "        actionArg = \"copy\"\n",
        "    elif Mode == \"Sync\":\n",
        "        actionArg = \"sync\"\n",
        "    elif Mode == \"Verify\":\n",
        "        actionArg = \"check\"\n",
        "    elif Mode == \"Dedupe\":\n",
        "        actionArg = \"dedupe largest\"\n",
        "    elif Mode == \"Clean Empty Dirs\":\n",
        "        actionArg = \"rmdirs\"\n",
        "    elif Mode == \"Empty Trash\":\n",
        "        actionArg = \"delete\"\n",
        "    else:\n",
        "        actionArg = \"move\"\n",
        "\n",
        "    return actionArg\n",
        "\n",
        "\n",
        "def populateCompareArg():\n",
        "    if Compare == \"Mod-Time\":\n",
        "        compareArg = \"--ignore-size\"\n",
        "    elif Compare == \"Size\":\n",
        "        compareArg = \"--size-only\"\n",
        "    elif Compare == \"Checksum\":\n",
        "        compareArg = \"-c --ignore-size\"\n",
        "    else:\n",
        "        compareArg = \"-c\"\n",
        "\n",
        "    return compareArg\n",
        "\n",
        "\n",
        "def populateOptimizeGDriveArg():\n",
        "    return (\n",
        "        \"--buffer-size 256M \\\n",
        "            --drive-chunk-size 256M \\\n",
        "                --drive-upload-cutoff 256M \\\n",
        "                    --drive-acknowledge-abuse \\\n",
        "                        --drive-keep-revision-forever\"\n",
        "        if OPTIMIZE_GDRIVE\n",
        "        else \"--buffer-size 128M\"\n",
        "    )\n",
        "\n",
        "\n",
        "def populateGDriveCopyArg():\n",
        "    if BRIDGE_TRANSFER and memGiB() < 13:\n",
        "        global TRANSFERS, CHECKERS\n",
        "        TRANSFERS, CHECKERS = 10, 80\n",
        "    else:\n",
        "        pass\n",
        "    return \"--disable copy\" if BRIDGE_TRANSFER else \"--drive-server-side-across-configs\"\n",
        "\n",
        "\n",
        "def populateStatsArg():\n",
        "    statsArg = \"--stats-one-line --stats=5s\" if SIMPLE_LOG else \"--stats=5s -P\"\n",
        "    if LOG_LEVEL != \"OFF\":\n",
        "        statsArg += \" -v\" if SIMPLE_LOG else \"-vv\"\n",
        "    elif LOG_LEVEL == \"INFO\":\n",
        "        statsArg += \" --log-level INFO\"\n",
        "    elif LOG_LEVEL == \"ERROR\":\n",
        "        statsArg += \" --log-level ERROR\"\n",
        "    else:\n",
        "        statsArg += \" --log-level DEBUG\"\n",
        "    return statsArg\n",
        "\n",
        "\n",
        "def populateSyncModeArg():\n",
        "    if Mode != \"Sync\":\n",
        "        return \"\"\n",
        "    elif SYNC_MODE == \"Delete before transfering\":\n",
        "        syncModeArg = \"--delete-before\"\n",
        "    elif SYNC_MODE == \"Delete after transfering\":\n",
        "        syncModeArg = \"--delete-after\"\n",
        "    else:\n",
        "        syncModeArg = \"--delete-during\"\n",
        "    if SYNC_TRACK_RENAME:\n",
        "        syncModeArg += \" --track-renames\"\n",
        "    return syncModeArg\n",
        "\n",
        "\n",
        "def populateDedupeModeArg():\n",
        "    if DEDUPE_MODE == \"Interactive\":\n",
        "        dedupeModeArg = \"--dedupe-mode interactive\"\n",
        "    elif DEDUPE_MODE == \"Skip\":\n",
        "        dedupeModeArg = \"--dedupe-mode skip\"\n",
        "    elif DEDUPE_MODE == \"First\":\n",
        "        dedupeModeArg = \"--dedupe-mode first\"\n",
        "    elif DEDUPE_MODE == \"Newest\":\n",
        "        dedupeModeArg = \"--dedupe-mode newest\"\n",
        "    elif DEDUPE_MODE == \"Oldest\":\n",
        "        dedupeModeArg = \"--dedupe-mode oldest\"\n",
        "    elif DEDUPE_MODE == \"Rename\":\n",
        "        dedupeModeArg = \"--dedupe-mode rename\"\n",
        "    else:\n",
        "        dedupeModeArg = \"--dedupe-mode largest\"\n",
        "\n",
        "    return dedupeModeArg\n",
        "\n",
        "\n",
        "def generateCmd():\n",
        "    sharedFilesArgs = (\n",
        "        \"--drive-shared-with-me --files-from /content/upload.txt --no-traverse\"\n",
        "        if COPY_SHARED_FILES\n",
        "        else \"\"\n",
        "    )\n",
        "\n",
        "    logFileArg = f\"--log-file /content/rclone_log.txt -vv -P\"\n",
        "\n",
        "    args = [\n",
        "        \"rclone\",\n",
        "        f\"--config {PATH_RClone_Config}/rclone.conf\",\n",
        "        '--user-agent \"Mozilla\"',\n",
        "        populateActionArg(),\n",
        "        f'\"{Source}\"',\n",
        "        f'\"{Destination}\"' if Mode in (\"Move\", \"Copy\", \"Sync\") else \"\",\n",
        "        f\"--transfers {str(TRANSFERS)}\",\n",
        "        f\"--checkers {str(CHECKERS)}\",\n",
        "    ]\n",
        "\n",
        "    if Mode == \"Verify\":\n",
        "        args.append(\"--one-way\")\n",
        "    elif Mode == \"Empty Trash\":\n",
        "        args.append(\"--drive-trashed-only --drive-use-trash=false\")\n",
        "    else:\n",
        "        args.extend(\n",
        "            [\n",
        "                populateGDriveCopyArg(),\n",
        "                populateSyncModeArg(),\n",
        "                populateCompareArg(),\n",
        "                populateOptimizeGDriveArg(),\n",
        "                \"-u\" if SKIP_NEWER_FILE else \"\",\n",
        "                \"--ignore-existing\" if SKIP_EXISTED else \"\",\n",
        "                \"--no-update-modtime\" if SKIP_UPDATE_MODTIME else \"\",\n",
        "                \"--one-file-system\" if ONE_FILE_SYSTEM else \"\",\n",
        "                \"--tpslimit 95 --tpslimit-burst 40\" if THROTTLE_TPS else \"\",\n",
        "                \"--fast-list\" if FAST_LIST else \"\",\n",
        "                \"--delete-empty-src-dirs\" if Mode == \"Move\" else \"\",\n",
        "            ]\n",
        "        )\n",
        "    args.extend(\n",
        "        [\n",
        "            \"-n\" if DRY_RUN else \"\",\n",
        "            populateStatsArg() if not RECORD_LOGFILE else logFileArg,\n",
        "            sharedFilesArgs,\n",
        "            Extra_Arguments,\n",
        "        ]\n",
        "    )\n",
        "\n",
        "    return args\n",
        "\n",
        "\n",
        "def executeRclone():\n",
        "    prepareSession()\n",
        "    if Source.strip() == \"\":\n",
        "        displayOutput(\"❌ The Source field is empty.\")\n",
        "        return\n",
        "    if checkAvailable(\"/content/rclone_log.txt\"):\n",
        "        if not checkAvailable(\"/content/logfiles\"):\n",
        "            runSh(\"mkdir -p -m 666 /content/logfiles\")\n",
        "        job = accessSettingFile(\"job.txt\")\n",
        "        runSh(\n",
        "            f'mv /content/rclone_log.txt /content/logfiles/{job[\"title\"]}_{job[\"status\"]}_logfile.txt'\n",
        "        )\n",
        "\n",
        "    onGoingJob = {\n",
        "        \"title\": f'{Mode}_{Source}_{Destination}_{_dt.now().strftime(\"%a-%H-%M-%S\")}',\n",
        "        \"status\": \"ongoing\",\n",
        "    }\n",
        "    accessSettingFile(\"job.txt\", onGoingJob)\n",
        "\n",
        "    cmd = \" \".join(generateCmd())\n",
        "    runSh(cmd, output=True)\n",
        "    displayOutput(Mode, \"success\")\n",
        "\n",
        "    onGoingJob[\"status\"] = \"finished\"\n",
        "    accessSettingFile(\"job.txt\", onGoingJob)\n",
        "\n",
        "executeRclone()\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GUqn6vGlfZ_x",
        "cellView": "form"
      },
      "source": [
        "#@markdown <center><h3>Rclone MOUNT / UNMOUNT</h3>Mount the remote as file system on a mountpoint.</center>\n",
        "Cache_Directory = \"DISK\" #@param [\"RAM\", \"DISK\"]\n",
        "import os\n",
        "from IPython.display import HTML, clear_output\n",
        "import uuid\n",
        "import ipywidgets as widgets\n",
        "from google.colab import output\n",
        "import re\n",
        "#####################################\n",
        "if not os.path.exists(\"/root/.ipython/rlab_utils.py\"):\n",
        "  from shlex import split as _spl\n",
        "  from subprocess import run\n",
        "\n",
        "  shellCmd = \"wget -qq https://biplobsd.github.io/RLabClone/res/rlab_utils.py \\\n",
        "                  -O /root/.ipython/rlab_utils.py\"\n",
        "  run(_spl(shellCmd))\n",
        "\n",
        "from rlab_utils import (\n",
        "    runSh,\n",
        "    prepareSession,\n",
        "    PATH_RClone_Config,\n",
        ")\n",
        "\n",
        "class MakeButton(object):\n",
        "  def __init__(self, title, callback, style):\n",
        "    self._title = title\n",
        "    self._callback = callback\n",
        "    self._style = style\n",
        "  def _repr_html_(self):\n",
        "    callback_id = 'button-' + str(uuid.uuid4())\n",
        "    output.register_callback(callback_id, self._callback)\n",
        "    if self._style != \"\":\n",
        "      style_html = \"p-Widget jupyter-widgets jupyter-button widget-button mod-\" + self._style\n",
        "    else:\n",
        "      style_html = \"p-Widget jupyter-widgets jupyter-button widget-button\"\n",
        "    template = \"\"\"<button class=\"{style_html}\" id=\"{callback_id}\">{title}</button>\n",
        "        <script>\n",
        "          document.querySelector(\"#{callback_id}\").onclick = (e) => {{\n",
        "            google.colab.kernel.invokeFunction('{callback_id}', [], {{}})\n",
        "            e.preventDefault();\n",
        "          }};\n",
        "        </script>\"\"\"\n",
        "    html = template.format(title=self._title, callback_id=callback_id, style_html=style_html)\n",
        "    return html\n",
        "  \n",
        "def ShowAC():\n",
        "  clear_output(wait=True)\n",
        "  display(\n",
        "      widgets.HBox(\n",
        "          [widgets.VBox(\n",
        "              [widgets.HTML(\n",
        "                  '''<h3 style=\"font-family:Trebuchet MS;color:#4f8bd6;margin-top:0px;\">\n",
        "                  Rclone available config...</h3>\n",
        "                  '''\n",
        "                  ),\n",
        "               mountNam]\n",
        "               )\n",
        "          ]\n",
        "          )\n",
        "      )\n",
        "  \n",
        "  display(HTML(\"<br>\"), MakeButton(\"Mount\", MountCMD, \"primary\"),\n",
        "          MakeButton(\"Unmount\", unmountCMD, \"danger\"))\n",
        "\n",
        "prepareSession()\n",
        "content = open(f\"{PATH_RClone_Config}/rclone.conf\").read()\n",
        "avCon = re.findall(r\"^\\[(.+)\\]$\", content, re.M)\n",
        "mountNam = widgets.Dropdown(options=avCon)\n",
        "\n",
        "if Cache_Directory == 'RAM':\n",
        "  cache_path = '/dev/shm'\n",
        "elif Cache_Directory == 'DISK':\n",
        "  os.makedirs('/tmp', exist_ok=True)\n",
        "  cache_path = '/tmp'\n",
        "\n",
        "def MountCMD():\n",
        "    mPoint = f\"/content/drives/{mountNam.value}\"\n",
        "    os.makedirs(mPoint, exist_ok=True)\n",
        "    cmd = rf\"rclone mount {mountNam.value}: {mPoint}\" \\\n",
        "      rf\" --config {PATH_RClone_Config}/rclone.conf\" \\\n",
        "      ' --user-agent \"Mozilla\"' \\\n",
        "      ' --buffer-size 256M' \\\n",
        "      ' --transfers 10' \\\n",
        "      ' --vfs-cache-mode full' \\\n",
        "      ' --vfs-cache-max-age 0h0m1s' \\\n",
        "      ' --vfs-cache-poll-interval 0m1s' \\\n",
        "      f' --cache-dir {cache_path}' \\\n",
        "      ' --allow-other' \\\n",
        "      ' --daemon'\n",
        "\n",
        "    if runSh(cmd, shell=True) == 0:\n",
        "      print(f\"Mount success! - \\t{mPoint}\")\n",
        "    else:\n",
        "      print(f\"Mount failed! - \\t{mPoint}\")\n",
        "\n",
        "def unmountCMD():\n",
        "  mPoint = f\"/content/drives/{mountNam.value}\"\n",
        "  if os.system(f\"fusermount -uz {mPoint}\") == 0:\n",
        "    runSh(f\"rm -r {mPoint}\")\n",
        "    print(f\"Unmounted success! - \\t{mPoint}\")\n",
        "  else:\n",
        "    runSh(f\"fusermount -uz {mPoint}\", output=True)\n",
        "\n",
        "ShowAC()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "whyei9P7GIsM",
        "cellView": "form"
      },
      "source": [
        "#@markdown <center><h3>Rclone webui</h3></center><br>\n",
        "import os, signal\n",
        "import random\n",
        "import string\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "from urllib.parse import urlparse\n",
        "import time\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "#@markdown Default <br>&emsp;username : user<br>&emsp;password : pass\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "runW = get_ipython()\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "if not os.path.exists(\"/root/.ipython/rlab_utils.py\"):\n",
        "  from shlex import split as _spl\n",
        "  from subprocess import run\n",
        "\n",
        "  shellCmd = \"wget -qq https://biplobsd.github.io/RLabClone/res/rlab_utils.py \\\n",
        "                  -O /root/.ipython/rlab_utils.py\"\n",
        "  run(_spl(shellCmd))\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    displayUrl,\n",
        "    findProcess,\n",
        "    CWD,\n",
        "    textAn,\n",
        "    checkAvailable\n",
        ")\n",
        "from rlab_utils import (\n",
        "    displayOutput,\n",
        "    checkAvailable,\n",
        "    prepareSession,\n",
        "    PATH_RClone_Config,\n",
        "    accessSettingFile,\n",
        "    memGiB,\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "prepareSession()\n",
        "pid = findProcess(\"rclone\", \"rcd\", isPid=True)\n",
        "try:\n",
        "  os.kill(int(pid), signal.SIGTERM)\n",
        "except TypeError:\n",
        "  pass\n",
        "cmd = \"rclone rcd --rc-web-gui --rc-addr :5572\" \\\n",
        "      \" --rc-serve\" \\\n",
        "      \" --rc-user=user --rc-pass=pass\" \\\n",
        "      \" --rc-no-auth\" \\\n",
        "      rf\" --config {PATH_RClone_Config}/rclone.conf\" \\\n",
        "      ' --user-agent \"Mozilla\"' \\\n",
        "      ' --transfers 16' \\\n",
        "      \" &\"\n",
        "runSh(cmd, shell=True)\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['rclone', 5572, 'http'],\n",
        "                            ['filebrowser', 4000, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/filebrowserRclone.yml\", 4099]\n",
        ").start('rclone', displayB=False)\n",
        "# output\n",
        "clear_output()\n",
        "displayUrl(Server, pNamU='Rclone webUI : ', \n",
        "           ExUrl=fr\"https://user:pass@{urlparse(Server['url']).hostname}\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "-BeHgvH1aNIJ",
        "cellView": "form"
      },
      "source": [
        "#@markdown <center><h3>Create/Edit Rclone config</h3>Create a new remote with name, type and options.<br><font size=1px>After created your config file download that. Next time just upload and you are done!</font></center>\n",
        "import os, urllib.request\n",
        "from IPython.display import HTML\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"SA\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "runW = get_ipython()\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "#####################################\n",
        "\n",
        "if not os.path.exists(\"/root/.ipython/rlab_utils.py\"):\n",
        "  from shlex import split as _spl\n",
        "  from subprocess import run\n",
        "\n",
        "  shellCmd = \"wget -qq https://biplobsd.github.io/RLabClone/res/rlab_utils.py \\\n",
        "                  -O /root/.ipython/rlab_utils.py\"\n",
        "  run(_spl(shellCmd))\n",
        "\n",
        "from rlab_utils import (\n",
        "    prepareSession,\n",
        "    PATH_RClone_Config,\n",
        "    runSh\n",
        ")\n",
        "from ocr import (\n",
        "    PortForward_wrapper\n",
        ")\n",
        "\n",
        "###################################\n",
        "import codecs\n",
        "import contextlib\n",
        "import locale\n",
        "import os\n",
        "import pty\n",
        "import select\n",
        "import signal\n",
        "import subprocess\n",
        "import sys\n",
        "import termios\n",
        "import time\n",
        "\n",
        "\n",
        "from IPython.utils import text\n",
        "import six\n",
        "from google.colab import _ipython\n",
        "from google.colab import _message\n",
        "from google.colab.output import _tags\n",
        "\n",
        "# Linux read(2) limits to 0x7ffff000 so stay under that for clarity.\n",
        "_PTY_READ_MAX_BYTES_FOR_TEST = 2**20  # 1MB\n",
        "\n",
        "_ENCODING = 'UTF-8'\n",
        "\n",
        "class ShellResult(object):\n",
        "  \"\"\"Result of an invocation of the shell magic.\n",
        "\n",
        "  Note: This is intended to mimic subprocess.CompletedProcess, but has slightly\n",
        "  different characteristics, including:\n",
        "    * CompletedProcess has separate stdout/stderr properties. A ShellResult\n",
        "      has a single property containing the merged stdout/stderr stream,\n",
        "      providing compatibility with the existing \"!\" shell magic (which this is\n",
        "      intended to provide an alternative to).\n",
        "    * A custom __repr__ method that returns output. When the magic is invoked as\n",
        "      the only statement in the cell, Python prints the string representation by\n",
        "      default. The existing \"!\" shell magic also returns output.\n",
        "  \"\"\"\n",
        "\n",
        "  def __init__(self, args, returncode, command_output):\n",
        "    self.args = args\n",
        "    self.returncode = returncode\n",
        "    self.output = command_output\n",
        "\n",
        "  def check_returncode(self):\n",
        "    if self.returncode:\n",
        "      raise subprocess.CalledProcessError(\n",
        "          returncode=self.returncode, cmd=self.args, output=self.output)\n",
        "\n",
        "  def _repr_pretty_(self, p, cycle):  # pylint:disable=unused-argument\n",
        "    # Note: When invoking the magic and not assigning the result\n",
        "    # (e.g. %shell echo \"foo\"), Python's default semantics will be used and\n",
        "    # print the string representation of the object. By default, this will\n",
        "    # display the __repr__ of ShellResult. Suppress this representation since\n",
        "    # the output of the command has already been displayed to the output window.\n",
        "    if cycle:\n",
        "      raise NotImplementedError\n",
        "\n",
        "\n",
        "def _configure_term_settings(pty_fd):\n",
        "  term_settings = termios.tcgetattr(pty_fd)\n",
        "  # ONLCR transforms NL to CR-NL, which is undesirable. Ensure this is disabled.\n",
        "  # http://man7.org/linux/man-pages/man3/termios.3.html\n",
        "  term_settings[1] &= ~termios.ONLCR\n",
        "\n",
        "  # ECHOCTL echoes control characters, which is undesirable.\n",
        "  term_settings[3] &= ~termios.ECHOCTL\n",
        "\n",
        "  termios.tcsetattr(pty_fd, termios.TCSANOW, term_settings)\n",
        "\n",
        "\n",
        "def _run_command(cmd, clear_streamed_output):\n",
        "  \"\"\"Calls the shell command, forwarding input received on the stdin_socket.\"\"\"\n",
        "  locale_encoding = locale.getpreferredencoding()\n",
        "  if locale_encoding != _ENCODING:\n",
        "    raise NotImplementedError(\n",
        "        'A UTF-8 locale is required. Got {}'.format(locale_encoding))\n",
        "\n",
        "  parent_pty, child_pty = pty.openpty()\n",
        "  _configure_term_settings(child_pty)\n",
        "\n",
        "  epoll = select.epoll()\n",
        "  epoll.register(\n",
        "      parent_pty,\n",
        "      (select.EPOLLIN | select.EPOLLOUT | select.EPOLLHUP | select.EPOLLERR))\n",
        "\n",
        "  try:\n",
        "    temporary_clearer = _tags.temporary if clear_streamed_output else _no_op\n",
        "\n",
        "    with temporary_clearer(), _display_stdin_widget(\n",
        "        delay_millis=500) as update_stdin_widget:\n",
        "      # TODO(b/115531839): Ensure that subprocesses are terminated upon\n",
        "      # interrupt.\n",
        "      p = subprocess.Popen(\n",
        "          cmd,\n",
        "          shell=True,\n",
        "          executable='/bin/bash',\n",
        "          stdout=child_pty,\n",
        "          stdin=child_pty,\n",
        "          stderr=child_pty,\n",
        "          close_fds=True)\n",
        "      # The child PTY is only needed by the spawned process.\n",
        "      os.close(child_pty)\n",
        "\n",
        "      return _monitor_process(parent_pty, epoll, p, cmd, update_stdin_widget)\n",
        "  finally:\n",
        "    epoll.close()\n",
        "    os.close(parent_pty)\n",
        "\n",
        "\n",
        "class _MonitorProcessState(object):\n",
        "\n",
        "  def __init__(self):\n",
        "    self.process_output = six.StringIO()\n",
        "    self.is_pty_still_connected = True\n",
        "\n",
        "\n",
        "def _monitor_process(parent_pty, epoll, p, cmd, update_stdin_widget):\n",
        "  \"\"\"Monitors the given subprocess until it terminates.\"\"\"\n",
        "  state = _MonitorProcessState()\n",
        "\n",
        "  # A single UTF-8 character can span multiple bytes. os.read returns bytes and\n",
        "  # could return a partial byte sequence for a UTF-8 character. Using an\n",
        "  # incremental decoder is incrementally fed input bytes and emits UTF-8\n",
        "  # characters.\n",
        "  decoder = codecs.getincrementaldecoder(_ENCODING)()\n",
        "\n",
        "  num_interrupts = 0\n",
        "  echo_status = None\n",
        "  while True:\n",
        "    try:\n",
        "      result = _poll_process(parent_pty, epoll, p, cmd, decoder, state)\n",
        "      if result is not None:\n",
        "        return result\n",
        "      term_settings = termios.tcgetattr(parent_pty)\n",
        "      new_echo_status = bool(term_settings[3] & termios.ECHO)\n",
        "      if echo_status != new_echo_status:\n",
        "        update_stdin_widget(new_echo_status)\n",
        "        echo_status = new_echo_status\n",
        "    except KeyboardInterrupt:\n",
        "      try:\n",
        "        num_interrupts += 1\n",
        "        if num_interrupts == 1:\n",
        "          p.send_signal(signal.SIGINT)\n",
        "        elif num_interrupts == 2:\n",
        "          # Process isn't responding to SIGINT and user requested another\n",
        "          # interrupt. Attempt to send SIGTERM followed by a SIGKILL if the\n",
        "          # process doesn't respond.\n",
        "          p.send_signal(signal.SIGTERM)\n",
        "          time.sleep(0.5)\n",
        "          if p.poll() is None:\n",
        "            p.send_signal(signal.SIGKILL)\n",
        "      except KeyboardInterrupt:\n",
        "        # Any interrupts that occur during shutdown should not propagate.\n",
        "        pass\n",
        "\n",
        "      if num_interrupts > 2:\n",
        "        # In practice, this shouldn't be possible since\n",
        "        # SIGKILL is quite effective.\n",
        "        raise\n",
        "\n",
        "\n",
        "def _poll_process(parent_pty, epoll, p, cmd, decoder, state):\n",
        "  \"\"\"Polls the process and captures / forwards input and output.\"\"\"\n",
        "\n",
        "  terminated = p.poll() is not None\n",
        "  if terminated:\n",
        "    termios.tcdrain(parent_pty)\n",
        "    # We're no longer interested in write events and only want to consume any\n",
        "    # remaining output from the terminated process. Continuing to watch write\n",
        "    # events may cause early termination of the loop if no output was\n",
        "    # available but the pty was ready for writing.\n",
        "    epoll.modify(parent_pty,\n",
        "                 (select.EPOLLIN | select.EPOLLHUP | select.EPOLLERR))\n",
        "\n",
        "  output_available = False\n",
        "\n",
        "  events = epoll.poll()\n",
        "  input_events = []\n",
        "  for _, event in events:\n",
        "    if event & select.EPOLLIN:\n",
        "      output_available = True\n",
        "      raw_contents = os.read(parent_pty, _PTY_READ_MAX_BYTES_FOR_TEST)\n",
        "      import re\n",
        "      decoded_contents = re.sub(r\"http:\\/\\/127.0.0.1:53682\", Server[\"url\"], \n",
        "                                decoder.decode(raw_contents))\n",
        "      sys.stdout.write(decoded_contents)\n",
        "      state.process_output.write(decoded_contents)\n",
        "\n",
        "    if event & select.EPOLLOUT:\n",
        "      # Queue polling for inputs behind processing output events.\n",
        "      input_events.append(event)\n",
        "\n",
        "    # PTY was disconnected or encountered a connection error. In either case,\n",
        "    # no new output should be made available.\n",
        "    if (event & select.EPOLLHUP) or (event & select.EPOLLERR):\n",
        "      state.is_pty_still_connected = False\n",
        "\n",
        "  for event in input_events:\n",
        "    # Check to see if there is any input on the stdin socket.\n",
        "    # pylint: disable=protected-access\n",
        "    input_line = _message._read_stdin_message()\n",
        "    # pylint: enable=protected-access\n",
        "    if input_line is not None:\n",
        "      # If a very large input or sequence of inputs is available, it's\n",
        "      # possible that the PTY buffer could be filled and this write call\n",
        "      # would block. To work around this, non-blocking writes and keeping\n",
        "      # a list of to-be-written inputs could be used. Empirically, the\n",
        "      # buffer limit is ~12K, which shouldn't be a problem in most\n",
        "      # scenarios. As such, optimizing for simplicity.\n",
        "      input_bytes = bytes(input_line.encode(_ENCODING))\n",
        "      os.write(parent_pty, input_bytes)\n",
        "\n",
        "  # Once the process is terminated, there still may be output to be read from\n",
        "  # the PTY. Wait until the PTY has been disconnected and no more data is\n",
        "  # available for read. Simply waiting for disconnect may be insufficient if\n",
        "  # there is more data made available on the PTY than we consume in a single\n",
        "  # read call.\n",
        "  if terminated and not state.is_pty_still_connected and not output_available:\n",
        "    sys.stdout.flush()\n",
        "    command_output = state.process_output.getvalue()\n",
        "    return ShellResult(cmd, p.returncode, command_output)\n",
        "\n",
        "  if not output_available:\n",
        "    # The PTY is almost continuously available for reading input to provide\n",
        "    # to the underlying subprocess. This means that the polling loop could\n",
        "    # effectively become a tight loop and use a large amount of CPU. Add a\n",
        "    # slight delay to give resources back to the system while monitoring the\n",
        "    # process.\n",
        "    # Skip this delay if we read output in the previous loop so that a partial\n",
        "    # read doesn't unnecessarily sleep before reading more output.\n",
        "    # TODO(b/115527726): Rather than sleep, poll for incoming messages from\n",
        "    # the frontend in the same poll as for the output.\n",
        "    time.sleep(0.1)\n",
        "\n",
        "\n",
        "@contextlib.contextmanager\n",
        "def _display_stdin_widget(delay_millis=0):\n",
        "  \"\"\"Context manager that displays a stdin UI widget and hides it upon exit.\n",
        "\n",
        "  Args:\n",
        "    delay_millis: Duration (in milliseconds) to delay showing the widget within\n",
        "      the UI.\n",
        "\n",
        "  Yields:\n",
        "    A callback that can be invoked with a single argument indicating whether\n",
        "    echo is enabled.\n",
        "  \"\"\"\n",
        "  shell = _ipython.get_ipython()\n",
        "  display_args = ['cell_display_stdin', {'delayMillis': delay_millis}]\n",
        "  _message.blocking_request(*display_args, parent=shell.parent_header)\n",
        "\n",
        "  def echo_updater(new_echo_status):\n",
        "    # Note: Updating the echo status uses colab_request / colab_reply on the\n",
        "    # stdin socket. Input provided by the user also sends messages on this\n",
        "    # socket. If user input is provided while the blocking_request call is still\n",
        "    # waiting for a colab_reply, the input will be dropped per\n",
        "    # https://github.com/googlecolab/colabtools/blob/56e4dbec7c4fa09fad51b60feb5c786c69d688c6/google/colab/_message.py#L100.\n",
        "    update_args = ['cell_update_stdin', {'echo': new_echo_status}]\n",
        "    _message.blocking_request(*update_args, parent=shell.parent_header)\n",
        "\n",
        "  yield echo_updater\n",
        "\n",
        "  hide_args = ['cell_remove_stdin', {}]\n",
        "  _message.blocking_request(*hide_args, parent=shell.parent_header)\n",
        "\n",
        "\n",
        "@contextlib.contextmanager\n",
        "def _no_op():\n",
        "  yield\n",
        "\n",
        "###################################\n",
        "prepareSession()\n",
        "\n",
        "PORT_FORWARD = \"localhost\" #@param [\"ngrok\", \"localhost\"]\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['rcloneConfig', 53682, 'http'], \n",
        "                            ['pyload', 8000, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/rclonePyload.yml\", 4074]\n",
        ").start('rcloneConfig', displayB=False, v=False)\n",
        "\n",
        "printData = \"\"\"Copy this URL,\n",
        "  It's needed for authentication purposes.\n",
        "  After completing your account select, you redirect to a website, after back\n",
        "  you need to change http://127.0.0.0:53682 to {}\"\"\".format(Server['url'])\n",
        "print(printData)\n",
        "display(HTML('&emsp;&emsp;<a href=\"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/rclone_config_create.gif\" target=\"_blank\">See how</a><br><br>'))\n",
        "print(f\"{Server['url']}\", end=\"\\n\\n\")\n",
        "_run_command(f\"rclone config --config {PATH_RClone_Config}/rclone.conf\", False)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "uB-vkVstVpVs",
        "cellView": "form"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "# @markdown #### ⬅️ Execute Upload Local File\n",
        "MODE = \"RCONFIG\"  # @param ['UTILS', 'RCONFIG', 'RCONFIG_append', \"GENERATELIST\"]\n",
        "REMOTE = \"mnc\"  # @param {type:\"string\"}\n",
        "QUERY_PATTERN = \"\"  # @param {type:\"string\"}\n",
        "# @markdown #### <font size=1px>For not able to upload local file : https://stackoverflow.com/a/58661947</font>\n",
        "# ================================================================ #\n",
        "\n",
        "from os import path as _p\n",
        "\n",
        "if not _p.exists(\"/root/.ipython/rlab_utils.py\"):\n",
        "    from shlex import split as _spl\n",
        "    from subprocess import run  # nosec\n",
        "\n",
        "    shellCmd = \"wget -qq https://biplobsd.github.io/RLabClone/res/rlab_utils.py \\\n",
        "                    -O /root/.ipython/rlab_utils.py\"\n",
        "    run(_spl(shellCmd))  # nosec\n",
        "\n",
        "import importlib, rlab_utils\n",
        "from google.colab import files  # pylint: disable=import-error #nosec\n",
        "from rlab_utils import checkAvailable, runSh, PATH_RClone_Config, prepareSession\n",
        "\n",
        "\n",
        "def generateUploadList():\n",
        "    prepareSession()\n",
        "    if checkAvailable(\"/content/upload.txt\"):\n",
        "        runSh(\"rm -f upload.txt\")\n",
        "    runSh(\n",
        "        f\"rclone --config {PATH_RClone_Config}/rclone.conf lsf {REMOTE}: --include '{QUERY_PATTERN}' --drive-shared-with-me --files-only --max-depth 1 > /content/upload.txt\",\n",
        "        shell=True,  # nosec\n",
        "    )\n",
        "\n",
        "\n",
        "def uploadLocalFiles():\n",
        "    prepareSession()\n",
        "    if MODE == \"UTILS\":\n",
        "        filePath = \"/root/.ipython/rlab_utils.py\"\n",
        "    elif MODE in (\"RCONFIG\", \"RCONFIG_append\"):\n",
        "        filePath = f\"{PATH_RClone_Config}/rclone.conf\"\n",
        "    else:\n",
        "        pass\n",
        "\n",
        "    try:\n",
        "      if checkAvailable(filePath):\n",
        "        runSh(f\"rm -f {filePath}\")\n",
        "      print(\"Select file from your computer.\\n\")\n",
        "      uploadedFile = files.upload()\n",
        "      fileNameDictKeys = uploadedFile.keys()\n",
        "      fileNo = len(fileNameDictKeys)\n",
        "      if fileNo > 1:\n",
        "          for fn in fileNameDictKeys:\n",
        "              runSh(f'rm -f \"/content/{fn}\"')\n",
        "          return print(\"\\nPlease only upload a single config file.\")\n",
        "      elif fileNo == 0:\n",
        "          return print(\"\\nFile upload cancelled.\")\n",
        "      elif fileNo == 1:\n",
        "          for fn in fileNameDictKeys:\n",
        "              if checkAvailable(f\"/content/{fn}\"):\n",
        "                  if MODE == \"RCONFIG_append\":\n",
        "                    import urllib\n",
        "                    urllib.request.urlretrieve(\"https://biplobsd.github.io/RLabClone/res/rclonelab/rclone.conf\",\n",
        "                                               \"/usr/local/sessionSettings/rclone.conf\")\n",
        "                    with open(f\"/content/{fn}\", 'r+') as r:\n",
        "                      new_data = r.read()\n",
        "                      runSh(f'rm -f \"/content/{fn}\"')\n",
        "                    with open(filePath, 'r+') as f:\n",
        "                      old_data = f.read()\n",
        "                      f.seek(0)\n",
        "                      f.truncate(0)\n",
        "                      f.write(old_data + new_data)\n",
        "                    print(\"\\nUpdate completed.\")\n",
        "                  else:\n",
        "                    runSh(f'mv -f \"/content/{fn}\" {filePath}')\n",
        "                    runSh(f\"chmod 666 {filePath}\")\n",
        "                    runSh(f'rm -f \"/content/{fn}\"')\n",
        "                    importlib.reload(rlab_utils)\n",
        "                    print(\"\\nUpload completed.\")\n",
        "              return\n",
        "      else:\n",
        "          print(\"\\nNo file\")\n",
        "          return\n",
        "    except:\n",
        "      return print(\"\\nUpload process Error.\")\n",
        "\n",
        "\n",
        "if MODE == \"GENERATELIST\":\n",
        "    generateUploadList()\n",
        "else:\n",
        "    uploadLocalFiles()\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "RG2o5dgK5P4j",
        "cellView": "form"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "# @markdown #### ⬅️ Download config file.\n",
        "MODE = \"RCONFIG\"  # @param ['UTILS', 'RCONFIG']\n",
        "# ================================================================ #\n",
        "from google.colab import files\n",
        "\n",
        "def downloadFile():\n",
        "  if MODE == \"UTILS\":\n",
        "      filePath = \"/root/.ipython/rlab_utils.py\"\n",
        "  elif MODE == \"RCONFIG\":\n",
        "      filePath = f\"{PATH_RClone_Config}/rclone.conf\"\n",
        "  else:\n",
        "      pass\n",
        "  try:\n",
        "    files.download(filePath)\n",
        "  except FileNotFoundError:\n",
        "    print(\"File not found!\")\n",
        "\n",
        "if __name__ == \"__main__\":\n",
        "  downloadFile()\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wpaNBHNPTcbn"
      },
      "source": [
        ""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "XvusoBejYdEO"
      },
      "source": [
        "## <img height=\"50\" src=\"https://anonfiles.com/img/favicon/favicon-32x32-anonfiles.png\"/>__Anonfiles__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "G9ow5Fb2YkVZ",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://anonfiles.com/static/logo.png' height=\"200\"/></center>\n",
        "#@markdown <br><center>_Upload File_</center>\n",
        "import requests\n",
        "url = 'https://api.anonfiles.com/upload'\n",
        "FILE_PATH = \"\" # @param {type: \"string\"}\n",
        "x = requests.post(url, files = {'file': open(FILE_PATH,'rb')},)\n",
        "print(\"DOWNLOAD LINK: \" + x.json()[\"data\"][\"file\"][\"url\"][\"full\"])"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oyORiVSzq6ok"
      },
      "source": [
        "## <img height=\"50\" src=\"https://bayfiles.com/static/logo.png\"/> __Bayfiles__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "bwtfD5nUjwnD"
      },
      "source": [
        "#@markdown <br><center><img src='https://bayfiles.com/static/logo.png' height=\"200\"/></center>\n",
        "#@markdown <br><center>_Upload File_</center>\n",
        "\n",
        "import requests\n",
        "url = 'https://api.bayfiles.com/upload'\n",
        "FILE_PATH = \"\" # @param {type: \"string\"}\n",
        "x = requests.post(url, files = {'file': open(FILE_PATH,'rb')},)\n",
        "print(\"DOWNLOAD LINK: \" + x.json()[\"data\"][\"file\"][\"url\"][\"full\"])"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7U8mMA7ZBRMl"
      },
      "source": [
        "#`sysTools(`<font size=\"3px\" color=\"#5fa4d3\">`Wetty`</font> , <font size=\"3px\" color=\"#57cb6c\">`Glances`</font> , <font size=\"3px\" color=\"#d60f0f\">`NoMachine`</font> , <font size=\"3px\" color=\"#05ba02\">`_['>ssh']`</font> , <font size=\"3px\" color=\"#f8f800\">`noVNC`</font> , <font size=\"3px\" color=\"#aaabad\">`IceWM`</font> , <font size=\"3px\" color=\"#00c853\"> `netdata`</font>`)`"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "6bkIZt2oYnnQ"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "# @markdown #### ⬅️ Check VM's Status\n",
        "Check_IP = True \n",
        "Loop_Check = False  #@param {type:\"boolean\"}\n",
        "Loop_Interval = 3600 \n",
        "# ================================================================ #\n",
        "\n",
        "import time, requests\n",
        "from IPython.display import clear_output\n",
        "\n",
        "Loop = True\n",
        "try:\n",
        "    while Loop == True:\n",
        "        clear_output(wait=True)\n",
        "        !top -bcn1 -w512\n",
        "        sessionIP = f\"\\nYour Public IP: {requests.get('http://ip.42.pl/raw').text}:12121\"\n",
        "        if Check_IP: \n",
        "            print(sessionIP)             \n",
        "        print(\"====\")\n",
        "        if Loop_Check == False:\n",
        "            Loop = False\n",
        "        else:\n",
        "            time.sleep(Loop_Interval)\n",
        "except:\n",
        "  clear_output()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wZMZjX127rmx"
      },
      "source": [
        "## Crash Colab to clear all RAM"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "OH3xVkwWmPYL",
        "cellView": "form"
      },
      "source": [
        "#@title ← ឵឵ ឵Run this cell to crash your current Runtime if you're low on memory\n",
        "#@markdown <i>After crashing, you'll have access to all the preoccupied storage. Then it'll help you for Rclone cache file storage increase (Recommend for a first run this cell) </i>\n",
        "some_str = ' ' * 5120000000000"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F4eLcy-vYZia"
      },
      "source": [
        "## <img src='https://raw.githubusercontent.com/butlerx/wetty/main/src/assets/favicon.ico' height=\"25\" alt=\"Wetty\"/> ___Wetty___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FMd-AFnVYZid",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://raw.githubusercontent.com/butlerx/wetty/main/src/assets/favicon.ico' height=\"200\" alt=\"wetty\"/></center>\n",
        "#@markdown <center><h3>Wetty<br />Terminal in browser over http/https.</h3></center><br>\n",
        "import os, tarfile\n",
        "import urllib.request\n",
        "from IPython.display import clear_output\n",
        "from subprocess import Popen\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "os.makedirs('tools/temp', exist_ok=True)\n",
        "\n",
        "if not os.path.exists(\"tools/wetty/wetty\"):\n",
        "  ## Build then run\n",
        "  # os.system(\"git clone https://github.com/butlerx/wetty.git tools/wetty\")\n",
        "  # Popen(\n",
        "  #     'npm install'.split(), cwd='tools/wetty').wait()\n",
        "  # Popen('npm run-script build'.split(), cwd='tools/wetty').wait()\n",
        "  # Popen('npm i -g'.split(), cwd='tools/wetty').wait()\n",
        "\n",
        "  ## run now\n",
        "  wettyBF = 'https://github.com/biplobsd/temp/releases/download/v0.001/wetty.tar.gz'\n",
        "  fileSN = 'tools/temp/wetty.tar.gz'\n",
        "  urllib.request.urlretrieve(wettyBF, fileSN)\n",
        "  with tarfile.open(fileSN, 'r:gz') as t:t.extractall('tools/')\n",
        "  os.remove(fileSN)\n",
        "\n",
        "if not findProcess(\"wetty\", \"--port\"):\n",
        "  # Popen(\n",
        "  #     r'wetty --port 4343 --bypasshelmet \\\n",
        "  #     -b \"/\" -c \"/bin/bash\"'.split(), \n",
        "  #     cwd='/content')\n",
        "  Popen(\n",
        "      r'tools/wetty/wetty --port 4343 --bypasshelmet \\\n",
        "      -b \"/\" -c \"/bin/bash\"'.split(), \n",
        "      cwd='/content')\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['wetty', '4343', 'http']], \n",
        "    REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/wetty.yml\", 31199]\n",
        ").start('wetty', displayB=True)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yQGcOoAJJOZV"
      },
      "source": [
        "## <img src='https://nicolargo.github.io/glances/public/images/glances.png' height=\"25\" alt=\"Glances\"/> ___Glances___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "i2klARBiyo4I",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://nicolargo.github.io/glances/public/images/glances.png' height=\"200\" alt=\"Glances\"/></center>\n",
        "#@markdown <center><h3>Glances<br />Glances is a cross-platform system monitoring tool written in Python.</h3></center><br>\n",
        "import os\n",
        "import urllib.request\n",
        "from IPython.display import clear_output\n",
        "from subprocess import Popen\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"JP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    displayUrl\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "if not os.path.exists(\"/usr/local/bin/glances\"):\n",
        "  os.system(\n",
        "      \"pip3 install https://github.com/nicolargo/glances/archive/master.zip\")\n",
        "  os.system('pip3 install Bottle')\n",
        "  os.system(\n",
        "      \"pip3 install 'glances[gpu,ip]'\")\n",
        "\n",
        "if not findProcess(\"glances\", \"--webserver\"):\n",
        "  Popen(\n",
        "      'glances --webserver --port 61208 --time 0 --enable-process-extended \\\n",
        "      --byte --diskio-show-ramfs --fs-free-space \\\n",
        "      --disable-check-update'.split()\n",
        "      )\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['glances', '61208', 'http']], \n",
        "    REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/glances.yml\", 31499]\n",
        ").start('glances', displayB=False)\n",
        "displayUrl(server, EcUrl=\"/0\", btc='g')\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "m5jM8gHbzWUW"
      },
      "source": [
        "## <img src='https://raw.githubusercontent.com/biplobsd/OneClickRun/master/res/appdata/NoMachine/logo_E3oZpVzB_400x400.png' height=\"25\" alt=\"NoMachine\" /> ___NoMachine___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4TByiWdUD7bu",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://raw.githubusercontent.com/biplobsd/OneClickRun/master/res/appdata/NoMachine/logo_E3oZpVzB_400x400.png' height=\"200\" alt=\"noMachine\"/></center>\n",
        "#@markdown <center>NoMachine<br><h3>Free Remote Desktop For Everybody</h3></center><br>\n",
        "import os\n",
        "import tarfile\n",
        "import urllib.request\n",
        "import shutil\n",
        "import time\n",
        "from IPython.display import HTML, clear_output\n",
        "from subprocess import Popen\n",
        "from urllib.parse import urlparse\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = False\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"US\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"ngrok\" #@param [\"ngrok\", \"argotunnel\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "runW = get_ipython()\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    textAn,\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs(\"tools/nomachine\", exist_ok=True)\n",
        "os.makedirs(\"/root/.icewm\", exist_ok=True)\n",
        "\n",
        "# password ganarate\n",
        "try:\n",
        "  print(f\"Found old password! : {password}\")\n",
        "except:\n",
        "  password = 'nomachine'\n",
        "\n",
        "clear_output()\n",
        "\n",
        "start = time.time()\n",
        "if not os.path.exists(\"tools/nomachine/NX/bin/nxserver\"):\n",
        "  textAn(\"Wait for almost 49 seconds. It's doing for NoMachine ready ...\")\n",
        "\n",
        "  runW.system_raw('apt update --quiet --force-yes')\n",
        "\n",
        "  # Minimal install \n",
        "  runW.system_raw(\n",
        "      'apt install --quiet --force-yes --no-install-recommends \\\n",
        "      icewm x11-xserver-utils firefox xterm pcmanfm')\n",
        "\n",
        "  # icewm theme\n",
        "  with open('/root/.icewm/theme', 'w') as w:\n",
        "    w.write('Theme=\"NanoBlue/default.theme\"')\n",
        "  \n",
        "  # with open('/root/.icewm/toolbar', 'w') as w:\n",
        "  #   w.write('prog \"chromium\" ! chromium-browser --no-sandbox')\n",
        "\n",
        "  # nomachine\n",
        "  staticUrl = \"https://github.com/biplobsd/temp/releases/download/6.9.2_1/nomachine_6.9.2_1_x86_64.tar.gz\"\n",
        "  configUrl = \"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/res/appdata/NoMachine/NXetc.tar.gz\"\n",
        "  \n",
        "  output_file = 'tools/nomachine/nm.tar.gz'\n",
        "  config_file = 'tools/nomachine/etc.tar.gz'\n",
        "  urllib.request.urlretrieve(staticUrl, output_file)\n",
        "  urllib.request.urlretrieve(configUrl, config_file)\n",
        "  \n",
        "  with tarfile.open(output_file, 'r:gz') as t:t.extractall('tools/nomachine')\n",
        "  runSh('./nxserver --install', cd='tools/nomachine/NX', shell=True)\n",
        "  runSh('./nxserver --stop', cd='tools/nomachine/NX/bin', shell=True)\n",
        "  \n",
        "  shutil.rmtree('tools/nomachine/NX/etc')\n",
        "  with tarfile.open(config_file, 'r:gz') as t:t.extractall('tools/nomachine/NX')\n",
        "  os.remove(config_file)\n",
        "  \n",
        "  os.remove(output_file)\n",
        "  runSh('./nxserver --startup', cd='tools/nomachine/NX/bin', shell=True)\n",
        "  runW.system_raw(\"echo root:$password | chpasswd\")\n",
        "\n",
        "end = time.time()\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "Server = PortForward_wrapper(PORT_FORWARD, TOKEN, USE_FREE_TOKEN,\n",
        "                             [['nomachine', 4000, 'tcp']], REGION.lower(), \n",
        "               [f\"{HOME}/.ngrok2/nomachine.yml\", 8459])\n",
        "\n",
        "data = Server.start('nomachine', displayB=False)\n",
        "clear_output()\n",
        "user = os.popen('whoami').read()\n",
        "\n",
        "# Colors\n",
        "bttxt = 'hsla(10, 50%, 85%, 1)'\n",
        "btcolor = 'hsla(10, 86%, 56%, 1)'\n",
        "btshado = 'hsla(10, 40%, 52%, .4)'\n",
        "\n",
        "if PORT_FORWARD is \"argotunnel\":\n",
        "  host = data['url']\n",
        "  display(HTML(\"\"\"<style>@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200,900');  :root {   --text-color: \"\"\"+bttxt+\"\"\";   --shadow-color: \"\"\"+btshado+\"\"\";   --btn-color: \"\"\"+btcolor+\"\"\";   --bg-color: #141218; }  * {   box-sizing: border-box; } button { position:relative; padding: 10px 20px;     border: none;   background: none;      font-family: \"Source Code Pro\";   font-weight: 900;font-size: 100%;     color: var(--text-color);      background-color: var(--btn-color);   box-shadow: var(--shadow-color) 2px 2px 22px;   border-radius: 4px;    z-index: 0;overflow: hidden; -webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;}  button:focus {   outline-color: transparent;   box-shadow: var(--btn-color) 2px 2px 22px; }  .right::after, button::after {   content: var(--content);   display: block;   position: absolute;   white-space: nowrap;   padding: 40px 40px;   pointer-events:none; }  button::after{   font-weight: 200;   top: -30px;   left: -20px; }   .right, .left {   position: absolute;   width: 100%;   height: 100%;   top: 0; } .right {   left: 66%; } .left {   right: 66%; } .right::after {   top: -30px;   left: calc(-66% - 20px);      background-color: var(--bg-color);   color:transparent;   transition: transform .4s ease-out;   transform: translate(0, -90%) rotate(0deg) }  button:hover .right::after {   transform: translate(0, -47%) rotate(0deg) }  button .right:hover::after {   transform: translate(0, -50%) rotate(-7deg) }  button .left:hover ~ .right::after {   transform: translate(0, -50%) rotate(7deg) }  /* bubbles */ button::before {   content: '';   pointer-events: none;   opacity: .6;   background:     radial-gradient(circle at 20% 35%,  transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 75% 44%, transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--text-color) 5px, var(--text-color) 6px, transparent 6px);    width: 100%;   height: 300%;   top: 0;   left: 0;   position: absolute;   animation: bubbles 5s linear infinite both; }  @keyframes bubbles {   from {     transform: translate();   }   to {     transform: translate(0, -66.666%);   } }.zui-table {    border: solid 1px #DDEEEE;    border-collapse: collapse;    border-spacing: 0;    font: normal 13px;}.zui-table thead th {    background-color: #DDEFEF;    border: solid 1px #DDEEEE;    color: #0000009e;    padding: 10px;    text-align: left;}.zui-table tbody td {border: solid 1px #effff97a;color: #ffffffd1;    padding: 10px;}</style><center><button><table class=\"zui-table blueBG\"><p>NoMachine config<p><thead>        <tr><th>Username</th> <th>Password</th><th>Terminal command</th>        </tr>    </thead>    <tbody>        <tr><td>\"\"\"+user+\"\"\"</td><td>\"\"\"+password+\"\"\"</td><td>cloudflared access tcp --hostname \"\"\"+host+\"\"\" --url localhost:4000</td></tr></tbody></table><a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://youtu.be/LR32upTUm9E\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))\n",
        "elif PORT_FORWARD is 'ngrok':\n",
        "  data = urlparse(data['url'])\n",
        "  host = data.hostname\n",
        "  port = str(data.port)\n",
        "  display(HTML(\"\"\"<style>@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200,900');  :root {   --text-color: \"\"\"+bttxt+\"\"\";   --shadow-color: \"\"\"+btshado+\"\"\";   --btn-color: \"\"\"+btcolor+\"\"\";   --bg-color: #141218; }  * {   box-sizing: border-box; } button { position:relative; padding: 10px 20px;     border: none;   background: none;      font-family: \"Source Code Pro\";   font-weight: 900;font-size: 100%;     color: var(--text-color);      background-color: var(--btn-color);   box-shadow: var(--shadow-color) 2px 2px 22px;   border-radius: 4px;    z-index: 0;overflow: hidden; -webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;}  button:focus {   outline-color: transparent;   box-shadow: var(--btn-color) 2px 2px 22px; }  .right::after, button::after {   content: var(--content);   display: block;   position: absolute;   white-space: nowrap;   padding: 40px 40px;   pointer-events:none; }  button::after{   font-weight: 200;   top: -30px;   left: -20px; }   .right, .left {   position: absolute;   width: 100%;   height: 100%;   top: 0; } .right {   left: 66%; } .left {   right: 66%; } .right::after {   top: -30px;   left: calc(-66% - 20px);      background-color: var(--bg-color);   color:transparent;   transition: transform .4s ease-out;   transform: translate(0, -90%) rotate(0deg) }  button:hover .right::after {   transform: translate(0, -47%) rotate(0deg) }  button .right:hover::after {   transform: translate(0, -50%) rotate(-7deg) }  button .left:hover ~ .right::after {   transform: translate(0, -50%) rotate(7deg) }  /* bubbles */ button::before {   content: '';   pointer-events: none;   opacity: .6;   background:     radial-gradient(circle at 20% 35%,  transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 75% 44%, transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--text-color) 5px, var(--text-color) 6px, transparent 6px);    width: 100%;   height: 300%;   top: 0;   left: 0;   position: absolute;   animation: bubbles 5s linear infinite both; }  @keyframes bubbles {   from {     transform: translate();   }   to {     transform: translate(0, -66.666%);   } }.zui-table {    border: solid 1px #DDEEEE;    border-collapse: collapse;    border-spacing: 0;    font: normal 13px;}.zui-table thead th {    background-color: #DDEFEF;    border: solid 1px #DDEEEE;    color: #0000009e;    padding: 10px;    text-align: left;}.zui-table tbody td {border: solid 1px #effff97a;color: #ffffffd1;    padding: 10px;}</style><center><button><table class=\"zui-table blueBG\"><p>NoMachine config<p><thead>        <tr><th>Username</th> <th>Password</th><th>Protocol</th>            <th>Host</th>            <th>Port</th>        </tr>    </thead>    <tbody>        <tr><td>\"\"\"+user+\"\"\"</td><td>\"\"\"+password+\"\"\"</td><td>NX</td><td>\"\"\"+host+\"\"\"</td><td>\"\"\"+port+\"\"\"</td></tr></tbody></table><a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/NoMachine_argoTunnel.gif\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "i5K4z5KBuGEx"
      },
      "source": [
        "## <img src='https://upload.wikimedia.org/wikipedia/commons/7/77/IceWM_Logo.png' height=\"25\" alt=\"iceWM\" /> ___IceWM with noVNC___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aNswlxgbuGE0",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://upload.wikimedia.org/wikipedia/commons/7/77/IceWM_Logo.png' height=\"200\" alt=\"iceWM\"/></center>\n",
        "#@markdown <center><h3>IceWM window manager</h3></center><br>\n",
        "import os\n",
        "import random\n",
        "import string\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "import time\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"IN\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "runW = get_ipython()\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    displayUrl,\n",
        "    findProcess,\n",
        "    CWD,\n",
        "    textAn,\n",
        ")\n",
        "\n",
        "# github latest releases tag define\n",
        "def latestTag(link):\n",
        "  import re\n",
        "  from urllib.request import urlopen\n",
        "  htmlF = urlopen(link+\"/releases/latest\").read().decode('UTF-8')\n",
        "  return re.findall(r'.+\\/tag\\/([.0-9A-Za-z]+)\".+/', htmlF)[0]\n",
        "\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs(\"tools/noVnc\", exist_ok=True)\n",
        "\n",
        "# password ganarate\n",
        "try:\n",
        "  print(f\"Found old password! : {password}\")\n",
        "except:\n",
        "  password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))\n",
        "\n",
        "\n",
        "clear_output()\n",
        "if not findProcess(\"Xtightvnc\", \":1\"):\n",
        "  textAn(\"Wait for almost 60 seconds. It's doing for VNC ready ...\")\n",
        "  os.makedirs(f'{HOME}/.vnc', exist_ok=True)\n",
        "  runW.system_raw('apt update -y')\n",
        "  runW.system_raw('apt install -y icewm firefox tightvncserver autocutsel xterm')\n",
        "\n",
        "  runW.system_raw(rf'echo \"{password}\" | vncpasswd -f > ~/.vnc/passwd')\n",
        "  data = \"\"\"\n",
        "#!/bin/bash\n",
        "xrdb $HOME/.Xresources\n",
        "xsetroot -solid black -cursor_name left_ptr\n",
        "autocutsel -fork\n",
        "icewm-session &\n",
        "\"\"\"\n",
        "  with open(f'{HOME}/.vnc/xstartup', 'w+') as wNow:\n",
        "    wNow.write(data)\n",
        "  os.chmod(f'{HOME}/.vnc/xstartup', 0o755)\n",
        "  os.chmod(f'{HOME}/.vnc/passwd', 0o400)\n",
        "  \n",
        "  runSh('sudo vncserver :1 -geometry 1440x870 -economictranslate -dontdisconnect &', \n",
        "        shell=True)\n",
        "\n",
        "  BASE_URL = \"https://github.com/geek1011/easy-novnc\"\n",
        "  LATEST_TAG = latestTag(BASE_URL)\n",
        "  output_file = \"tools/noVnc/easy-noVnc_linux-64bit\"\n",
        "  file_name = f\"easy-novnc_linux-64bit\"\n",
        "  urlF = f\"{BASE_URL}/releases/download/{LATEST_TAG}/{file_name}\"\n",
        "  try:\n",
        "    urllib.request.urlretrieve(urlF, output_file)\n",
        "  except OSError:\n",
        "    pass\n",
        "  os.chmod(output_file, 0o755)\n",
        "\n",
        "if not findProcess(\"easy-noVnc_linux-64bit\", '--addr \"0.0.0.0:6080\"'):\n",
        "  cmdDo = \"./easy-noVnc_linux-64bit --addr 0.0.0.0:6080 --port 5901\" \\\n",
        "    \" &\"\n",
        "  runSh(cmdDo, \n",
        "        cd=\"tools/noVnc/\",\n",
        "        shell=True)\n",
        "\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "Server = PortForward_wrapper(PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['vnc', 6080, 'http']], REGION.lower(), \n",
        "               [f\"{HOME}/.ngrok2/noVncFast.yml\", 4455])\n",
        "\n",
        "data = Server.start('vnc', displayB=False)\n",
        "# clear_output()\n",
        "displayUrl(data, pNamU='noVnc : ',\n",
        "            EcUrl=f'/vnc.html?autoconnect=true&password={password}&path=vnc&resize=scale&reconnect=true&show_dot=true')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4rMlpsk3jv5r"
      },
      "source": [
        "## <img src='http://icons.iconarchive.com/icons/blackvariant/button-ui-system-apps/1024/Terminal-icon.png' height=\"25\" alt=\"ssh\" />___SSH and noVNC___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "E4mhEMnmj5-s",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to create ssh tunnel</h3>\n",
        "#@markdown <br><center><img src='http://icons.iconarchive.com/icons/blackvariant/button-ui-system-apps/1024/Terminal-icon.png' height=\"200\" alt=\"ssh\"/></center>\n",
        "#@markdown <center><h3>Forward ssh now</h3></center><br>\n",
        "import os\n",
        "import random\n",
        "import string\n",
        "import urllib.request\n",
        "import time\n",
        "from IPython.display import HTML, clear_output\n",
        "from urllib.parse import urlparse\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = False\n",
        "CREATE_VNC = True # @param {type:\"boolean\"}\n",
        "CREATE_SSH = True # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"IN\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "runW = get_ipython()\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    displayUrl,\n",
        "    findProcess,\n",
        "    CWD,\n",
        "    textAn,\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "# password ganarate\n",
        "try:\n",
        "  print(f\"Found old password! : {password}\")\n",
        "except:\n",
        "  password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))\n",
        "\n",
        "if CREATE_SSH:\n",
        "  USE_FREE_TOKEN = False\n",
        "\n",
        "#Set root password\n",
        "if CREATE_SSH  and os.path.exists('/var/run/sshd') == False:\n",
        "  #Setup sshd\n",
        "  runSh('apt install -qq -o=Dpkg::Use-Pty=0 openssh-server pwgen')\n",
        "  runW.system_raw(\"echo root:$password | chpasswd\")\n",
        "  os.makedirs(\"/var/run/sshd\", exist_ok=True)\n",
        "  runW.system_raw('echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config')\n",
        "  runW.system_raw('echo \"PasswordAuthentication yes\" >> /etc/ssh/sshd_config')\n",
        "  runW.system_raw('echo \"LD_LIBRARY_PATH=/usr/lib64-nvidia\" >> /root/.bashrc')\n",
        "  runW.system_raw('echo \"export LD_LIBRARY_PATH\" >> /root/.bashrc')\n",
        "\n",
        "  #Run sshd\n",
        "  if not findProcess(\"/usr/sbin/sshd\", command=\"-D\"):\n",
        "    runSh('/usr/sbin/sshd -D &', shell=True)\n",
        "\n",
        "if CREATE_VNC:\n",
        "  clear_output()\n",
        "  #start = time.time()\n",
        "  textAn(\"Wait for almost 2 minutes. It's doing for VNC ready...\")\n",
        "  os.makedirs(f'{HOME}/.vnc', exist_ok=True)\n",
        "  runW.system_raw('add-apt-repository -y ppa:apt-fast/stable < /dev/null')\n",
        "  runW.system_raw('echo debconf apt-fast/maxdownloads string 16 | debconf-set-selections')\n",
        "  runW.system_raw('echo debconf apt-fast/dlflag boolean true | debconf-set-selections')\n",
        "  runW.system_raw('echo debconf apt-fast/aptmanager string apt-get | debconf-set-selections')\n",
        "  runW.system_raw('apt install -y apt-fast')\n",
        "  runW.system_raw('apt-fast install -y xfce4 xfce4-goodies firefox tightvncserver autocutsel')\n",
        "  runW.system_raw('update-alternatives --set x-terminal-emulator /usr/bin/xfce4-terminal.wrapper')\n",
        "  runW.system_raw(rf'echo \"{password}\" | vncpasswd -f > ~/.vnc/passwd')\n",
        "  data = \"\"\"\n",
        "#!/bin/bash\n",
        "xrdb $HOME/.Xresources\n",
        "autocutsel -fork\n",
        "startxfce4 &\n",
        "\"\"\"\n",
        "  with open(f'{HOME}/.vnc/xstartup', 'w+') as wNow:\n",
        "    wNow.write(data)\n",
        "  os.chmod(f'{HOME}/.vnc/xstartup', 0o755)\n",
        "  os.chmod(f'{HOME}/.vnc/passwd', 0o400)\n",
        "  runSh('sudo vncserver &', shell=True)\n",
        "  runSh(f'git clone https://github.com/novnc/noVNC.git {CWD}/noVNC')\n",
        "  runSh(\"bash noVNC/utils/launch.sh --listen 6080 --vnc localhost:5901 &\",\n",
        "        shell=True)\n",
        "  #end = time.time()\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "Server = PortForward_wrapper(PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['ssh', 22, 'tcp'], \n",
        "               ['vnc', 6080, 'http']], REGION.lower(), \n",
        "               [f\"{HOME}/.ngrok2/sshVnc.yml\", 4455])\n",
        "data = Server.start('ssh', displayB=False)\n",
        "\n",
        "# output\n",
        "data = urlparse(data['url'])\n",
        "Host,port = data.hostname, str(data.port)\n",
        "data2 = Server.start('vnc', displayB=False)\n",
        "clear_output()\n",
        "if CREATE_VNC:\n",
        "  displayUrl(data2, pNamU='noVnc : ',\n",
        "            EcUrl=f'/vnc.html?autoconnect=true&password={password}')\n",
        "if CREATE_SSH:\n",
        "  display(HTML(\"\"\"<style>@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200,900');  :root {   --text-color: hsla(210, 50%, 85%, 1);   --shadow-color: hsla(210, 40%, 52%, .4);   --btn-color: hsl(210, 80%, 42%);   --bg-color: #141218; }  * {   box-sizing: border-box; } button { position:relative; padding: 10px 20px;     border: none;   background: none;      font-family: \"Source Code Pro\";   font-weight: 900;font-size: 100%;     color: var(--text-color);      background-color: var(--btn-color);   box-shadow: var(--shadow-color) 2px 2px 22px;   border-radius: 4px;    z-index: 0;overflow: hidden; -webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;}  button:focus {   outline-color: transparent;   box-shadow: var(--btn-color) 2px 2px 22px; }  .right::after, button::after {   content: var(--content);   display: block;   position: absolute;   white-space: nowrap;   padding: 40px 40px;   pointer-events:none; }  button::after{   font-weight: 200;   top: -30px;   left: -20px; }   .right, .left {   position: absolute;   width: 100%;   height: 100%;   top: 0; } .right {   left: 66%; } .left {   right: 66%; } .right::after {   top: -30px;   left: calc(-66% - 20px);      background-color: var(--bg-color);   color:transparent;   transition: transform .4s ease-out;   transform: translate(0, -90%) rotate(0deg) }  button:hover .right::after {   transform: translate(0, -47%) rotate(0deg) }  button .right:hover::after {   transform: translate(0, -50%) rotate(-7deg) }  button .left:hover ~ .right::after {   transform: translate(0, -50%) rotate(7deg) }  /* bubbles */ button::before {   content: '';   pointer-events: none;   opacity: .6;   background:     radial-gradient(circle at 20% 35%,  transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 75% 44%, transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--text-color) 5px, var(--text-color) 6px, transparent 6px);    width: 100%;   height: 300%;   top: 0;   left: 0;   position: absolute;   animation: bubbles 5s linear infinite both; }  @keyframes bubbles {   from {     transform: translate();   }   to {     transform: translate(0, -66.666%);   } }.zui-table {    border: solid 1px #DDEEEE;    border-collapse: collapse;    border-spacing: 0;    font: normal 13px;}.zui-table thead th {    background-color: #DDEFEF;    border: solid 1px #DDEEEE;    color: #0000009e;    padding: 10px;    text-align: left;}.zui-table tbody td {border: solid 1px #effff97a;color: #ffffffd1;    padding: 10px;}</style>\"\"\"))\n",
        "  if 'argotunnel' is PORT_FORWARD:\n",
        "    display(HTML(\"\"\"<center><button> <table class=\"zui-table blueBG\"> <p>Ssh config <p> <thead> <tr> <th>Host</th><th>Port</th> <th>Password</th></tr></thead> <tbody> <tr> <td>\"\"\"+Host+\"\"\"</td> <td>\"\"\"+port+\"\"\"</td> <td>\"\"\"+password+\"\"\"</td> </tr> </tbody> </table> <center> <br> <table class=\"zui-table blueBG\"> <thead> <tr> <th></th> <th>Simple ssh command</th> </tr> </thead> <tbody> <tr> <td>Cloudflare tcp connect</td> <td>cloudflared access tcp --hostname \"\"\"+Host+\"\"\" --url localhost:22</td> </tr> <tr> <td>Terminal connect</td> <td>ssh root@localhost -p 22</td> </tr> <tr> <td>Socks5 proxy</td> <td>ssh -D 8282 -q -C -N root@localhost -p 22</td> </tr> </tbody> </table> </center> <a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/sshPreview_argotunnel.gif\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))\n",
        "  else:\n",
        "    display(HTML(\"\"\"<center><button> <table class=\"zui-table blueBG\"> <p>Ssh config <p> <thead> <tr> <th>Host</th> <th>Port</th> <th>Password</th> </tr> </thead> <tbody> <tr> <td>\"\"\"+Host+\"\"\"</td> <td>\"\"\"+port+\"\"\"</td> <td>\"\"\"+password+\"\"\"</td> </tr> </tbody> </table> <center> <br> <table class=\"zui-table blueBG\"> <thead> <tr> <th></th> <th>Simple ssh command</th> </tr> </thead> <tbody> <tr> <td>Terminal connect</td> <td>ssh root@\"\"\"+Host+\"\"\" -p \"\"\"+port+\"\"\"</td> </tr> <tr> <td>Socks5 proxy</td> <td>ssh -D 8282 -q -C -N root@\"\"\"+Host+\"\"\" -p \"\"\"+port+\"\"\"</td> </tr> </tbody> </table> </center> <a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/sshPreview.gif\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "FVvFaJrZ0bxg"
      },
      "source": [
        "## <img src='https://szyha.github.io/RcloneLabArchive/img/title_netdata.png' height=\"45\" alt=\"netdata\"/> <font size=1px>___netdata___</font>\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "H0Q1ERYX0Vrb",
        "cellView": "form"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "#@markdown <br><center><img src='https://szyha.github.io/RcloneLabArchive/img/title_netdata.png' height=\"100\" alt=\"netdata\"/></center>\n",
        "#@markdown <center><h3>Real-time Server Monitoring</h3></center><br>\n",
        "# ============================= FORM ============================= #\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AU\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "# ============================= FORM ============================= #\n",
        "# ================================================================ #\n",
        "\n",
        "import os, psutil, subprocess, shlex\n",
        "from IPython.display import HTML, clear_output\n",
        "import time\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    shellCmd = \"wget -qq https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\" \\\n",
        "                f\" -O {HOME}/.ipython/ocr.py\"\n",
        "    subprocess.run(shlex.split(shellCmd))\n",
        "\n",
        "from ocr import (\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    runSh,\n",
        "    textAn\n",
        ")\n",
        "\n",
        "def CheckProcess(process, command):\n",
        "  for pid in psutil.pids():\n",
        "    try:\n",
        "      p = psutil.Process(pid)\n",
        "      if process in p.name():\n",
        "        for arg in p.cmdline():\n",
        "          if command in str(arg):  \n",
        "            return True\n",
        "          else:\n",
        "            pass\n",
        "      else:\n",
        "        pass\n",
        "    except:\n",
        "      continue\n",
        "\n",
        "def Start_ServerMT():\n",
        "  if CheckProcess(\"netdata\", \"\") != True:\n",
        "    runSh('/usr/sbin/netdata', shell=True)\n",
        "\n",
        "loadingAn()      \n",
        "\n",
        "if not os.path.isfile(\"/usr/sbin/netdata\"):\n",
        "  clear_output(wait=True)\n",
        "  textAn(\"[Installing] Wait for almost 2 minutes...\")\n",
        "  #start = time.time()\n",
        "  get_ipython().system_raw(\"bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-wait --dont-start-it\")\n",
        "  #end = time.time()\n",
        "  clear_output(wait=True)\n",
        "Start_ServerMT()\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['netdata', 19999, 'http'], \n",
        "                            ['cloudcmd', 7007, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/netdataCloudcmd.yml\", 7044]\n",
        ").start('netdata', 'g')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qtAvLGCMBx1L"
      },
      "source": [
        "#`fileManager(`<font size=\"3px\" color=\"#96b5e6\">`ghfs`</font> , <font size=\"3px\" color=\"#2876f8\">`filebrowser`</font> , <font size=\"3px\" color=\"#41afe6\">`cloudCommander`</font>`)`"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "gz_8S4IOni_1"
      },
      "source": [
        "## ___Go HTTP File Server___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "oieqNETPNVny",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to START server</h3>\n",
        "#@markdown <br><br><center><h1>Go HTTP File Server</h1><br /><h6>Simple command line based HTTP file server to share local file system.</h6></center><br>\n",
        "import os\n",
        "from zipfile import ZipFile as ZZ\n",
        "import urllib.request, requests\n",
        "from IPython.display import clear_output\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "CUSTOM_VERSION = \"v1.10.9\"  # @param {type:\"string\"}\n",
        "LATEST_VERSION = False  # @param {type:\"boolean\"}\n",
        "#@markdown <small>&emsp;Version are available on <a target=\"_blank\" href=\"https://github.com/mjpclab/go-http-file-server/tags\">https://github.com/mjpclab/go-http-file-server/tags</a></small>\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "OUTPUT_DIR = \"/content\"  # @param {type:\"string\"}\n",
        "PORT_FORWARD = \"ngrok\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    CWD,\n",
        "    findPackageR\n",
        "    \n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "toolLocation = 'tools/ghfs'\n",
        "binaryF = f\"{toolLocation}/ghfs\"\n",
        "if not OUTPUT_DIR:\n",
        "  OUTPUT_DIR = CWD\n",
        "\n",
        "try:\n",
        "  if OUTPUT_DIR != OldP:\n",
        "    os.system(\"pkill ghfs\")\n",
        "except NameError:\n",
        "  pass\n",
        "  \n",
        "OldP = OUTPUT_DIR\n",
        "\n",
        "os.makedirs(toolLocation, exist_ok=True)\n",
        "\n",
        "if not os.path.exists(binaryF):\n",
        "  DZipBL = f\"{toolLocation}/Zipghfs.zip\"\n",
        "  if not LATEST_VERSION:\n",
        "    packagesUrl = findPackageR(\"mjpclab/go-http-file-server\", \"linux-amd64.zip\", CUSTOM_VERSION)\n",
        "  else:\n",
        "    packagesUrl = findPackageR(\"mjpclab/go-http-file-server\", \"linux-amd64.zip\")\n",
        "  urllib.request.urlretrieve(\n",
        "      packagesUrl, DZipBL)\n",
        "  with ZZ(DZipBL, 'r') as zip_ref:zip_ref.extractall(toolLocation)\n",
        "  os.remove(DZipBL)\n",
        "  os.chmod(binaryF, 0o777)\n",
        "\n",
        "if not findProcess(\"ghfs\", \"--listen-plain\"):\n",
        "  runSh(f'./ghfs --listen-plain 1717 -R \\\n",
        "         -a \":/:{OUTPUT_DIR}\" \\\n",
        "         --global-upload \\\n",
        "         --global-mkdir \\\n",
        "         --global-delete \\\n",
        "         --global-archive \\\n",
        "         --global-archive \\\n",
        "          &', \n",
        "        shell=True,\n",
        "        cd=\"tools/ghfs\")\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['ghfs', 1717, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/ghfs.yml\", 41717]\n",
        ").start('ghfs')\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "VSJRUHS7OZUJ"
      },
      "source": [
        "## <img src='https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg' height=\"25\" alt=\"filebrowser\" /> ___Filebrowser___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1oiHzQ1KOZUT",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to START server</h3>\n",
        "#@markdown <br><center><img src='https://raw.githubusercontent.com/filebrowser/logo/master/banner.svg' height=\"200\" alt=\"filebrowser\"/></center>\n",
        "#@markdown <center><h3>filebrowser<br />📂 Web File Browser which can be used as a middleware or standalone app</h3></center><br>\n",
        "import os, pathlib, zipfile, re\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "Version = '1.3.0'\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "# OUTPUT_DIR = \"\"  # @param {type:\"string\"}\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs('tools/filebrowser/', exist_ok=True)\n",
        "\n",
        "get_ipython().system_raw(r\"curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash\")\n",
        "if not findProcess(\"filebrowser\", \"--noauth\"):\n",
        "  runSh(\"filebrowser --noauth -r /content/ -p 4001 -d tools/filebrowser/filebrowser.db &\", shell=True)\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['rclone', 5572, 'http'],\n",
        "                            ['filebrowser', 4001, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/filebrowserRclone.yml\", 4099]\n",
        ").start('filebrowser')\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "INCWjTDRLye6"
      },
      "source": [
        "## <img src='https://biplobsd.github.io/RLabClone/img/title_cloud_commander.png' height=\"45\" alt=\"cloudCommander\"/><font size=1px>___Cloud Commander___</font>\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SX9z-_6PLpb8",
        "cellView": "form"
      },
      "source": [
        "# ============================= FORM ============================= #\n",
        "#@markdown <h3>⬅️ Install Cloud Commander (file manager)</h3>\n",
        "#@markdown <br><center><img src='https://biplobsd.github.io/RLabClone/img/title_cloud_commander.png' height=\"60\" alt=\"netdata\"/></center>\n",
        "# ================================================================ #\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AU\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "\n",
        "import os, psutil, time, urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "if os.path.isfile(\"/tools/node/bin/cloudcmd\") == False:\n",
        "  get_ipython().system_raw(\"npm cache clean -f && npm install -g n && n stable && npm i cloudcmd -g --force\")\n",
        "\n",
        "try:\n",
        "  urllib.request.urlopen('http://localhost:7007')\n",
        "except urllib.error.URLError:\n",
        "  !nohup cloudcmd --online --no-auth --show-config --show-file-name \\\n",
        "        --editor 'deepword' --packer 'tar' --port 7007 \\\n",
        "        --no-confirm-copy --confirm-move --name 'File Manager' \\\n",
        "        --keys-panel --no-contact --console --sync-console-path \\\n",
        "        --no-terminal --no-vim --columns 'name-size-date' --no-log &\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['netdata', 19999, 'http'], \n",
        "                            ['cloudcmd', 7007, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/netdataCloudcmd.yml\", 7044]\n",
        ").start('cloudcmd')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fhhDx-Svhrp3"
      },
      "source": [
        "#`programming(`<font size=\"3px\" color=\"#2876f8\">`code-server(VScode)`</font> , <font size=\"3px\" color=\"#4ebff7\">`flutter`</font> , <font size=\"3px\" color=\"#5c5c5c\">`kivy`</font>`)`"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "HsvEZZy0hrp6"
      },
      "source": [
        "## <img src='https://github.com/cdr/code-server/blob/main/src/browser/media/pwa-icon-512.png?raw=true' height=\"25\" alt=\"code-server\" /> ___code-server___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Kz1BR6kn31nJ",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to START server</h3>\n",
        "#@markdown <br><center><img src='https://github.com/cdr/code-server/blob/main/src/browser/media/pwa-icon-512.png?raw=true' height=\"200\" alt=\"code-server\"/></center>\n",
        "#@markdown <center><h3>code-server<br />code-server is VS Code running on a remote server, accessible through the browser.</h3></center><br>\n",
        "import os,sys, pathlib, zipfile, re, tarfile, shutil\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "Version = '1.3.0'\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AP\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "INSTALL_EXTENSION = \"ms-python.python ritwickdey.LiveServer ms-vscode.cpptools\"  # @param {type:\"string\"}\n",
        "USER_DATA_DIR = \"/content/tools/code-server/userdata\" # @param {type:\"string\"}\n",
        "OPEN_FOLDER = \"/content/\" #@param {type: \"string\"} \n",
        "TAG_NAME = \"3.2.0\" #@param {type: \"string\"} \n",
        "PACKAGES = \"x86_64\" #@param [\"x86_64\", \"amd64\"]\n",
        "RUN_LATEST = True # @param {type:\"boolean\"}\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    displayUrl,\n",
        "    findPackageR,\n",
        "    textAn\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs('tools/code-server/', exist_ok=True)\n",
        "os.makedirs('tools/temp', exist_ok=True)\n",
        "binFile = ''\n",
        "\n",
        "# Downloading code-server\n",
        "if not os.path.exists(\"tools/code-server/README.md\"):\n",
        "  os.system(\"apt install net-tools -y\")\n",
        "\n",
        "  BASE_URL = r\"https://github.com/cdr/code-server/\"\n",
        "  rawRdata = findPackageR(\"cdr/code-server\",\n",
        "                          f\"linux-{PACKAGES}.tar.gz\",\n",
        "                          False if RUN_LATEST else TAG_NAME,\n",
        "                          all_=True)\n",
        "  file_name = rawRdata['assets']['name']\n",
        "  urlF = rawRdata['assets']['browser_download_url']\n",
        "  output_file = \"tools/temp/code-server.tar.gz\"\n",
        "\n",
        "  textAn(f\"Installing code-server {rawRdata['tag_name']} ...\", ty=\"twg\")\n",
        "  \n",
        "  urllib.request.urlretrieve(urlF, output_file)\n",
        "  with tarfile.open(output_file, 'r:gz') as tar_ref:\n",
        "      tar_ref.extractall('tools/temp/')\n",
        "  os.renames(\"tools/temp/\"+file_name[:-7], 'tools/code-server/')\n",
        "  try:\n",
        "    pathlib.Path(output_file).unlink()\n",
        "  except FileNotFoundError:\n",
        "    pass\n",
        "  try:\n",
        "    os.remove('tools/code-server/lib/libstdc++.so.6')\n",
        "  except FileNotFoundError:\n",
        "    pass\n",
        "  \n",
        "  binList = ['bin/code-server',\n",
        "         'code-server']\n",
        "  for b in binList:\n",
        "    if os.path.exists('tools/code-server/'+b):\n",
        "      binFile = b\n",
        "      break\n",
        "      \n",
        "  # workspace settings\n",
        "  configScript = \"\"\"{\n",
        "  \"workbench.colorTheme\": \"Default Dark+\",\n",
        "  \"editor.minimap.enabled\": false\n",
        "}\n",
        "\"\"\"\n",
        "  os.makedirs(f'{OPEN_FOLDER}/.vscode', exist_ok=True)\n",
        "  with open(f'{OPEN_FOLDER}/.vscode/settings.json', 'w') as w:w.write(configScript)\n",
        "\n",
        "  if INSTALL_EXTENSION:\n",
        "    perExtension = INSTALL_EXTENSION.split(' ')\n",
        "    for l in perExtension:\n",
        "      cmdE = f\"./{binFile} \" \\\n",
        "      f\"--user-data-dir {USER_DATA_DIR}\" \\\n",
        "      f\" --install-extension {l}\"\n",
        "      runSh(cmdE, cd=\"tools/code-server\", shell=True)\n",
        "\n",
        "\n",
        "if not findProcess(\"node\", \"--extensions-dir\"):\n",
        "  cmdDo = f\"./{binFile} --auth none \" \\\n",
        "    f\" --port 5050 --user-data-dir {USER_DATA_DIR}\" \\\n",
        "    \" &\"\n",
        "  runSh(cmdDo, \n",
        "        cd=\"tools/code-server\",\n",
        "        shell=True)\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['code-server', 5050, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/code-server.yml\", 30499]\n",
        ").start('code-server', displayB=False)\n",
        "displayUrl(server, EcUrl=f\"/?folder={OPEN_FOLDER}\")\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "z434OhiBZ2ZZ",
        "cellView": "form"
      },
      "source": [
        "#@markdown <center><h3>Port forwarding</h3></center>\n",
        "import os, pathlib, zipfile, re\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True \n",
        "TOKEN = \"\" \n",
        "PORT_LIST = \"80, 8080, 4040\" #@param {type:\"string\"}\n",
        "\n",
        "#@markdown <font size=2px>Input PORT which you can want to forward. Separate two PORT between by comma. <br>Ex `80, 8080, 4040`</font>\n",
        "REGION = \"US\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    displayUrl,\n",
        "    textAn\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs('tools/', exist_ok=True)\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "m = []\n",
        "splitPortList = PORT_LIST.split(',')\n",
        "for p in splitPortList:\n",
        "  p = int(p)\n",
        "  m.append([f\"s{p}\", p, 'http'])\n",
        "\n",
        "\n",
        "PORT_FORWARD = \"ngrok\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, m, REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/randomPortOpen.yml\", 45535]\n",
        ")\n",
        "\n",
        "for l in m:\n",
        "  displayUrl(Server.start(l[0], displayB=False, v=False), \n",
        "             pNamU=f\"{l[0][1:]} -> \", cls=False)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0ZvyevbbU1Lb"
      },
      "source": [
        "## <img src='https://flutter.dev/images/favicon.png' height=\"25\" alt=\"Flutter\" /> ___Flutter___"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NiVRlnPQU1Ll"
      },
      "source": [
        "`💥Just run this is below cell. It will auto installing flutter and sdk and export PATH in PATH variable.💥`"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "d_VqkNZGU1Ln"
      },
      "source": [
        "# Flutter make env\n",
        "import os, urllib.request, time\n",
        "\n",
        "cmdtoolsUrl = \"https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip\"\n",
        "cmdtoolsFile = \"tools/cmdtools.zip\"\n",
        "gitUser = \"\"\n",
        "gitName = \"\"\n",
        "pathlist = \"\"\"\n",
        "/content/tools/sdk/platform-tools\n",
        "/content/tools/sdk/cmdline-tools/latest/bin\n",
        "/content/tools/flutter/bin\n",
        "\"\"\".split('\\n')\n",
        "tflist = list()\n",
        "\n",
        "if not (gitUser and gitName):\n",
        "  print(\"Error: set variable value: gitUser and gitName\")\n",
        "  time.sleep(0.5)\n",
        "  os._exit(1)\n",
        "\n",
        "for f in pathlist[1:-1]:tflist.append(os.path.exists(f))\n",
        "\n",
        "if False in tflist:\n",
        "  !git clone https://github.com/flutter/flutter.git -b stable tools/flutter &> /dev/null\n",
        "  urllib.request.urlretrieve(cmdtoolsUrl, cmdtoolsFile)\n",
        "  !unzip $cmdtoolsFile -d tools/sdk &> /dev/null\n",
        "  os.remove(cmdtoolsFile)\n",
        "  \n",
        "  # Github global user\n",
        "  !git config --global user.email $gitUser\n",
        "  !git config --global user.name $gitName\n",
        "\n",
        "  os.environ[\"ANDROID_HOME\"] = \"/content/tools/sdk\"\n",
        "  # os.environ[\"ANDROID_SDK_ROOT\"] = \"/content/tools/sdk\"\n",
        "  os.environ[\"PATH\"] += os.pathsep + os.pathsep.join(pathlist[1:-1])\n",
        "\n",
        "  !PATH=$PATH:/content/tools/sdk/tools/bin; \\\n",
        "  yes | sdkmanager --licenses --sdk_root=$ANDROID_HOME; \\\n",
        "  sdkmanager platform-tools --sdk_root=$ANDROID_HOME; \\\n",
        "  sdkmanager \"platforms;android-28\" --sdk_root=$ANDROID_HOME; \\\n",
        "  sdkmanager \"build-tools;28.0.3\" --sdk_root=$ANDROID_HOME; \\\n",
        "  sdkmanager \"cmdline-tools;latest\" --sdk_root=$ANDROID_HOME\n",
        "else:\n",
        "  print(\"Already sdk installed!\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "86JkFFBuQBw0"
      },
      "source": [
        "# FOR GITHUB PUSH, EVERY TIME ASKING USERNAME AND PASSWORD FIXS\n",
        "# git remote set-url origin https://<USERNAME>:<PASSWORD>@github.com/<REPOSITORIES>"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Wjn8Wf3qU1Lz"
      },
      "source": [
        "!flutter doctor -v"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Rrknu2q229FS"
      },
      "source": [
        "import os, time\n",
        "\n",
        "username = ''\n",
        "password = ''\n",
        "repo = ''\n",
        "\n",
        "if not (username and password and repo):\n",
        "  print(\"Error: set variable value: username, password and repo\")\n",
        "  time.sleep(0.5)\n",
        "  os._exit(1)\n",
        "\n",
        "if 'https://' in repo:repo = repo[8:]\n",
        "finalLink = f'https://{username}:{password}@{repo}'\n",
        "\n",
        "!git clone $finalLink project &> /dev/null; \\\n",
        "cd project; \\\n",
        "git remote set-url origin $finalLink"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "2houQHwCLXCb"
      },
      "source": [
        "with open('/root/.bashrc', 'a+') as w:\n",
        "  w.write(\n",
        "      'function _adb { adb connect 0.tcp.ngrok.io:$1; }'\n",
        "  )\n",
        "# Ex. _adb PORT\n",
        "#     _adb 53134"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ECEW6SBqLazX"
      },
      "source": [
        "## <img src='https://kivy.org/logos/kivy-logo-black-64.png' height=\"25\" alt=\"Kivy\" /> ___Kivy___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GUE_IHkTLazZ"
      },
      "source": [
        "## Make env for Kivy in google colab\n",
        "!pip3 install --user --upgrade buildozer cython virtualenv kivy kivymd \n",
        "!apt update;apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev\n",
        "!update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java\n",
        "!echo \"export PATH=$PATH:~/.local/bin/\" >> ~/.bashrc;source ~/.bashrc \n",
        "\n",
        "## << Build kivy android app >>>\n",
        "_cd = '/content/project'\n",
        "# !cd $_cd;yes | buildozer android debug deploy run logcat\n",
        "\n",
        "## ADB devices connecd over [wifi][internet]\n",
        "_adbTCPport = ''\n",
        "_adbToolsDir = '/root/.buildozer/android/platform/android-sdk/platform-tools'\n",
        "# !cd $_adbToolsDir;./adb connect 0.tcp.ngrok.io:$_adbTCPport\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "-ILpLUGBLaz0"
      },
      "source": [
        "## Set your git user on system global for git commit\n",
        "gitUserEmail = ''\n",
        "gitName = ''\n",
        "\n",
        "if (gitUserEmail and gitName):\n",
        "  !git config --global user.email $gitUserEmail\n",
        "  !git config --global user.name $gitName\n",
        "  print(\"Maybe Done!!\")\n",
        "else:\n",
        "  print(\"[error line 1,2] \\\n",
        "  Set your gitUserEmail and gitName variable\\n\\\n",
        "  like this \\n\\\n",
        "  gitUserEmail = 'abcd@yourmail.com'\\n\\\n",
        "  gitName = 'yourName'\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "I8SmSyeILaz4"
      },
      "source": [
        "## Download your private project via simple command!!\n",
        "gitUsername = ''\n",
        "gitPassword = ''\n",
        "gitRepo = ''\n",
        "cloneDir = '/content/project'\n",
        "\n",
        "if (gitPassword and gitUsername and gitRepo): \n",
        "  if 'https://' in gitRepo:gitRepo = gitRepo[8:]\n",
        "\n",
        "  finalLink = f'https://{gitUsername}:{gitPassword}@{gitRepo}'\n",
        "\n",
        "  !git clone $finalLink $cloneDir; \\\n",
        "  cd $cloneDir; \\\n",
        "  git remote set-url origin $finalLink\n",
        "else:\n",
        "  print(\"[error line 2,3,4] \\\n",
        "  Set your gitUsername, gitPassword and gitRepo variable\\n\\\n",
        "  like this \\n\\\n",
        "  gitUsername = 'abcd'\\n\\\n",
        "  gitPassword = 'abcd1234'\\n\\\n",
        "  gitRepo = 'https://github.com/abcd/kivyApp.git'\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Z1YQc9zZ45wW"
      },
      "source": [
        "#`pentester(`<font size=\"3px\" color=\"#06989a\">`SocialFish`</font> , <font size=\"3px\" color=\"#6279e3\">`L3MON`</font> , <font size=\"3px\" color=\"#0dd10d\">`SayCheese`</font> , <font size=\"3px\" color=\"#8c8c8c\">`Hashcat`</font>`)`"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yL1BRPGVwfbt"
      },
      "source": [
        "\n",
        "\n",
        "## <img src='https://raw.githubusercontent.com/UndeadSec/SocialFishMobile/master/content/logo.png' height=\"30\" alt=\"SocialFish\" /> SocialFish"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qPQcUGetoHU9",
        "cellView": "form"
      },
      "source": [
        "#@markdown <h3>⬅️ Click Here to START server</h3>\n",
        "#@markdown <br><center><img src='https://raw.githubusercontent.com/UndeadSec/SocialFishMobile/master/content/logo.png' height=\"100\" alt=\"SocialFish\"/></center>\n",
        "#@markdown <center><h3>SocialFish<br />Educational Phishing Tool & Information Collector</h3></center><br>\n",
        "import os, pathlib, zipfile, re\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"US\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "USERNAME = \"\"  # @param {type:\"string\"}\n",
        "PASSWORD = \"\"  # @param {type:\"string\"}\n",
        "#@markdown Default <br>&emsp;username : admin<br>&emsp;password : admin\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    displayUrl,\n",
        "    textAn\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "os.makedirs('tools/', exist_ok=True)\n",
        "\n",
        "# Downloading SocialFish\n",
        "if not os.path.exists(\"tools/SocialFish/SocialFish.py\"):\n",
        "  clear_output()\n",
        "  textAn(\"[Installing] Wait for almost 1 minutes...\")\n",
        "  # runSh('apt install -y texlive-latex-extra')\n",
        "  runSh('git clone https://github.com/biplobsd/SocialFish.git', cd='tools/')\n",
        "  runSh('pip install -r requirements.txt', cd='tools/SocialFish')\n",
        "  os.chmod(\"tools/SocialFish/SocialFish.py\", 0o755)\n",
        "\n",
        "if not findProcess(\"python3\", \"./SocialFish.py\"):\n",
        "  runCmd = \"./SocialFish.py \" \\\n",
        "    f\"{USERNAME if USERNAME else 'admin'} \" \\\n",
        "    f\"{PASSWORD if PASSWORD else 'admin'} &\"\n",
        "  runSh(runCmd, shell=True, cd='tools/SocialFish/')\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "PORT_FORWARD = \"argotunnel\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['SocialFish', 5000, 'http']],\n",
        "    REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/SocialFish.yml\", 4063]\n",
        ").start('SocialFish', displayB=False)\n",
        "\n",
        "displayUrl(Server, pNamU='SocialFish : ', \n",
        "           EcUrl=\"/neptune\")\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1EP1o4UDLS6f"
      },
      "source": [
        "## <img src='https://github.com/D3VL/L3MON/raw/master/server/assets/webpublic/logo.png' height=\"45\" alt=\"L3MON\" /><font size=1px>___L3MON DEMO___</font>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lgzzseqdMSTA",
        "cellView": "form"
      },
      "source": [
        "#@markdown <br><center><img src='https://github.com/D3VL/L3MON/raw/master/server/assets/webpublic/logo.png' height=\"100\" alt=\"L3MON\"/></center>\n",
        "#@markdown <center><h3>L3MON<br /> Remote Android Managment Suite</h3></center><br>\n",
        "import os, pathlib, zipfile, re, json, hashlib, time\n",
        "import urllib.request\n",
        "from IPython.display import HTML, clear_output\n",
        "from urllib.parse import urlparse\n",
        "\n",
        "#####################################\n",
        "USE_FREE_TOKEN = True  # @param {type:\"boolean\"}\n",
        "TOKEN = \"\"  # @param {type:\"string\"}\n",
        "REGION = \"AU\" #@param [\"US\", \"EU\", \"AP\", \"AU\", \"SA\", \"JP\", \"IN\"]\n",
        "USERNAME = \"\"  # @param {type:\"string\"}\n",
        "PASSWORD = \"\"  # @param {type:\"string\"}\n",
        "RUN_Dir = \"/content/tools/L3MON\"  # @param {type:\"string\"}\n",
        "#@markdown Default <br>&emsp;username : admin<br>&emsp;password : admin\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn,\n",
        "    PortForward_wrapper,\n",
        "    findProcess,\n",
        "    displayUrl,\n",
        "    textAn\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "if not RUN_Dir:\n",
        "  RUN_Dir = \"tools/L3MON\"\n",
        "os.makedirs(RUN_Dir, exist_ok=True)\n",
        "\n",
        "\n",
        "def md5(txt):\n",
        "  return hashlib.md5(txt.encode('utf-8')).hexdigest()\n",
        "\n",
        "# github latest releases tag define\n",
        "def latestTag(link):\n",
        "  import re\n",
        "  from urllib.request import urlopen\n",
        "  htmlF = urlopen(link+\"/releases/latest\").read().decode('UTF-8')\n",
        "  return re.findall(r'.+\\/tag\\/([.0-9A-Za-z]+)\".+/', htmlF)[0]\n",
        "\n",
        "# Downloading latest version of L3MON\n",
        "if not os.path.exists(f\"{RUN_Dir}/index.js\"):\n",
        "  BASE_URL = r\"https://github.com/D3VL/L3MON\"\n",
        "  LATEST_TAG = latestTag(BASE_URL)\n",
        "  urlF = f'{BASE_URL}/releases/download/{LATEST_TAG}/' \\\n",
        "              f'L3MON-v{LATEST_TAG}.zip'\n",
        "  urllib.request.urlretrieve(urlF, f'{RUN_Dir}/newL3MON.zip')\n",
        "  with zipfile.ZipFile(f'{RUN_Dir}/newL3MON.zip', 'r') as zip_ref:\n",
        "      zip_ref.extractall(RUN_Dir)\n",
        "  try:\n",
        "    pathlib.Path(f'{RUN_Dir}/newL3MON.zip').unlink()\n",
        "  except FileNotFoundError:\n",
        "    pass\n",
        "\n",
        "  # Installing L3MON\n",
        "  runSh('npm install pm2 -g')\n",
        "\n",
        "  # Uninstalling latest java\n",
        "  runSh('apt purge openjdk-\\* icedtea-\\* icedtea6-\\*')\n",
        "  # Install version 8\n",
        "  runSh('apt install openjdk-8-jre')\n",
        "\n",
        "  runSh('npm install', cd=RUN_Dir)\n",
        "  runSh('pm2 start index.js', cd=RUN_Dir)\n",
        "  time.sleep(2)\n",
        "  runSh('pm2 stop index.js', cd=RUN_Dir)\n",
        "  with open(f'{RUN_Dir}/maindb.json', 'r+') as f:\n",
        "      data = json.load(f)\n",
        "      if USERNAME:\n",
        "        data['admin']['username'] = USERNAME\n",
        "      if PASSWORD:\n",
        "        data['admin']['password'] = md5(PASSWORD)\n",
        "      else:\n",
        "        data['admin']['password'] = md5('admin')\n",
        "      f.seek(0)        \n",
        "      json.dump(data, f, indent=4)\n",
        "      f.truncate()\n",
        "\n",
        "if not findProcess('node' f'{RUN_Dir}/index.js'):\n",
        "  runSh('pm2 restart all', shell=True, cd=RUN_Dir)\n",
        "\n",
        "# START_SERVER\n",
        "# Ngrok region 'us','eu','ap','au','sa','jp','in'\n",
        "clear_output()\n",
        "PORT_FORWARD = \"ngrok\" #@param [\"ngrok\", \"localhost\", \"argotunnel\"]\n",
        "Server = PortForward_wrapper(\n",
        "    PORT_FORWARD, TOKEN, USE_FREE_TOKEN, [['L3MON', 22533, 'http'], \n",
        "                            ['L3MON_Client', 22222, 'http']], REGION.lower(), \n",
        "    [f\"{HOME}/.ngrok2/L3MON.yml\", 4051]\n",
        ")\n",
        "data = Server.start('L3MON')\n",
        "data2 = Server.start('L3MON_Client', displayB=False, v=False)\n",
        "data2 = urlparse(data2['url'])\n",
        "Host, port = data2.hostname, '80'\n",
        "\n",
        "display(HTML(\"\"\"<style>@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200,900');  :root {   --text-color: hsla(210, 50%, 85%, 1);   --shadow-color: hsla(210, 40%, 52%, .4);   --btn-color: hsl(210, 80%, 42%);   --bg-color: #141218; }  * {   box-sizing: border-box; } button { position:relative; padding: 10px 20px;     border: none;   background: none;      font-family: \"Source Code Pro\";   font-weight: 900;font-size: 20px;     color: var(--text-color);      background-color: var(--btn-color);   box-shadow: var(--shadow-color) 2px 2px 22px;   border-radius: 4px;    z-index: 0;overflow: hidden; -webkit-user-select: text;-moz-user-select: text;-ms-user-select: text;user-select: text;}  button:focus {   outline-color: transparent;   box-shadow: var(--btn-color) 2px 2px 22px; }  .right::after, button::after {   content: var(--content);   display: block;   position: absolute;   white-space: nowrap;   padding: 40px 40px;   pointer-events:none; }  button::after{   font-weight: 200;   top: -30px;   left: -20px; }   .right, .left {   position: absolute;   width: 100%;   height: 100%;   top: 0; } .right {   left: 66%; } .left {   right: 66%; } .right::after {   top: -30px;   left: calc(-66% - 20px);      background-color: var(--bg-color);   color:transparent;   transition: transform .4s ease-out;   transform: translate(0, -90%) rotate(0deg) }  button:hover .right::after {   transform: translate(0, -47%) rotate(0deg) }  button .right:hover::after {   transform: translate(0, -50%) rotate(-7deg) }  button .left:hover ~ .right::after {   transform: translate(0, -50%) rotate(7deg) }  /* bubbles */ button::before {   content: '';   pointer-events: none;   opacity: .6;   background:     radial-gradient(circle at 20% 35%,  transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 75% 44%, transparent 0,  transparent 2px, var(--text-color) 3px, var(--text-color) 4px, transparent 4px),     radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--text-color) 5px, var(--text-color) 6px, transparent 6px);    width: 100%;   height: 300%;   top: 0;   left: 0;   position: absolute;   animation: bubbles 5s linear infinite both; }  @keyframes bubbles {   from {     transform: translate();   }   to {     transform: translate(0, -66.666%);   } }.zui-table {    border: solid 1px #DDEEEE;    border-collapse: collapse;    border-spacing: 0;    font: normal 13px;}.zui-table thead th {    background-color: #DDEFEF;    border: solid 1px #DDEEEE;    color: #0000009e;    padding: 10px;    text-align: left;}.zui-table tbody td {border: solid 1px #effff97a;color: #ffffffd1;    padding: 10px;}</style><center><button><table class=\"zui-table blueBG\"><p>Listening address<p><thead>        <tr>        <th>Host</th>            <th>Port</th> </tr>    </thead>    <tbody>        <tr><td>\"\"\"+Host+\"\"\"</td><td>\"\"\"+port+\"\"\"</td></tr></tbody></table><a target=\"_blank\" style=\"text-decoration: none;color: hsla(210, 50%, 85%, 1);font-size: 10px;\" href=\"https://raw.githubusercontent.com/biplobsd/OneClickRun/master/img/L3MON_DEMO.gif\">NB. How to setup this's config. [Click ME]</a></button><center>\"\"\"))\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bOOBrzjbEGo_"
      },
      "source": [
        "## ___SayCheese v1.0___"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "U8-zrqX8EEah",
        "cellView": "form"
      },
      "source": [
        "#@markdown <center><h3><h2>SayCheese v1.0</h2>Remote Android Managment Suite</h3></center><br>\n",
        "import os, urllib.request\n",
        "from IPython.display import clear_output\n",
        "\n",
        "Version = '1.3.0'\n",
        "HOME = os.path.expanduser(\"~\")\n",
        "\n",
        "if not os.path.exists(f\"{HOME}/.ipython/ocr.py\"):\n",
        "    hCode = \"https://raw.githubusercontent.com/biplobsd/\" \\\n",
        "                \"OneClickRun/master/res/ocr.py\"\n",
        "    urllib.request.urlretrieve(hCode, f\"{HOME}/.ipython/ocr.py\")\n",
        "\n",
        "from ocr import (\n",
        "    runSh,\n",
        "    loadingAn\n",
        ")\n",
        "\n",
        "loadingAn()\n",
        "\n",
        "RUN_Dir = \"tools/\"\n",
        "os.makedirs(RUN_Dir, exist_ok=True)\n",
        "\n",
        "# Downloading saycheese\n",
        "if not os.path.exists(f'{RUN_Dir}/saycheese/saycheese.sh'):\n",
        "  runSh('apt update')\n",
        "  runSh('apt install -y php')\n",
        "  runSh('git clone https://github.com/thelinuxchoice/saycheese.git',\n",
        "        cd=RUN_Dir)\n",
        "clear_output()\n",
        "print('')\n",
        "!cd tools/saycheese && bash saycheese.sh"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6EGHwznNv05g",
        "cellView": "form"
      },
      "source": [
        "# @markdown #### Download output File\n",
        "makeArchive = True #@param {type:\"boolean\"}\n",
        "makeVideo = False #@param {type:\"boolean\"}\n",
        "from google.colab import files\n",
        "\n",
        "def downloadFile():\n",
        "  try:\n",
        "    if makeVideo:\n",
        "      !cd tools/saycheese && ffmpeg -y -r 1 -pattern_type glob -i 'cam*.png' -c:v libx264 out.mp4\n",
        "      files.download('tools/saycheese/out.mp4')\n",
        "    if makeArchive:\n",
        "      !cd tools/saycheese && zip -9 -r save.zip cam*.png out.mp4 saved.ip.txt\n",
        "      files.download('tools/saycheese/save.zip')\n",
        "  except FileNotFoundError:\n",
        "    print(\"File not found!\")\n",
        "\n",
        "if __name__ == \"__main__\":\n",
        "  downloadFile()\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kneesIsZMvBS"
      },
      "source": [
        ""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "P0Qca5EQNC_8"
      },
      "source": [
        "\n",
        "## <img src='https://3.bp.blogspot.com/-NQsUzeQ4bdM/W4pT-YNs7gI/AAAAAAAABvs/vVLj0kzk47MUDF_AfyveMYWpC5s09ZfFQCLcBGAs/s1600/cyber-crime-responsibility-secure-web%2Bcopy.jpg' height=\"30\" alt=\"HashCAT\" /> HashCat"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4AaNuK5TlI0E"
      },
      "source": [
        "\n",
        "```\n",
        "# This is formatted as code\n",
        "```\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "J83qlTJG-Tng"
      },
      "source": [
        "!nvidia-smi\n",
        "# Clone, build and install Hashcat\n",
        "!apt install cmake build-essential -y\n",
        "!apt install checkinstall git -y\n",
        "!git clone https://github.com/hashcat/hashcat.git\n",
        "!cd hashcat && git submodule update --init && make && make install\n",
        "!hashcat --version\n",
        "# Get wordlists\n",
        "!mkdir wordlists && cd wordlists\n",
        "\n",
        "# Clone the SecLists repository\n",
        "!git clone https://github.com/danielmiessler/SecLists wordlists/SecLists\n",
        "\n",
        "# Append 'hashcat' for demonstration purposes\n",
        "!echo \"hashcat!\" >> wordlists/SecLists/Passwords/Leaked-Databases/rockyou-75.txt\n",
        "\n",
        "!ls wordlists/SecLists\n",
        "!cp /content/wordlists/SecLists/Passwords/Leaked-Databases/rockyou.txt.tar.gz /content/wordlists\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Xj0DuuGz-yqM"
      },
      "source": [
        "!gzip -d /content/wordlists/rockyou.txt.tar.gz\n",
        "!tar -xf /content/wordlists/rockyou.txt.tar\n",
        "!rm -rf /content/wordlists/SecLists"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}