├── ico.ico ├── requirements.txt ├── README.md └── main.py /ico.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ergolyam/scoop-search-directory/HEAD/ico.ico -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | altgraph==0.17.2 2 | beautifulsoup4==4.10.0 3 | certifi==2021.10.8 4 | charset-normalizer==2.0.12 5 | future==0.18.2 6 | idna==3.3 7 | importlib-metadata==4.11.2 8 | lxml==4.8.0 9 | pefile==2021.9.3 10 | prettytable==3.2.0 11 | pyinstaller==4.9 12 | pyinstaller-hooks-contrib==2022.2 13 | pywin32-ctypes==0.2.0 14 | requests==2.27.1 15 | soupsieve==2.3.1 16 | typing-extensions==4.1.1 17 | urllib3==1.26.8 18 | wcwidth==0.2.5 19 | zipp==3.7.0 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # scoop-search-directory 2 | This Python script performs a search on the Scoop package manager repository and provides information on available applications. It allows users to install applications or add repositories directly from the command line interface (CLI). 3 | 4 | ### Usage 5 | 6 | 1. **Clone the repository**: Clone this repository using `git clone`. 7 | 2. **Navigate to the directory**: Go to the directory of the cloned repository. 8 | 3. **Install dependencies**: Install the required dependencies using `pip`. 9 | 10 | ```shell 11 | git clone https://github.com/grisha765/scoop-search-directory.git 12 | cd scoop-search-directory 13 | pip install requests beautifulsoup4 prettytable lxml 14 | ``` 15 | 16 | ### Run Script 17 | 18 | 1. Execute the script: Run the script and optionally provide a search query. 19 | 20 | ```shell 21 | python main.py [search_query] 22 | ``` 23 | 24 | ### Features 25 | 26 | 1. Searches the Scoop package manager repository based on the provided query. 27 | 2. Retrieves information about available applications including name, description, repository, version, and more. 28 | 3. Displays search results in a tabular format using PrettyTable. 29 | 4. Allows users to install applications or add repositories directly from the command line. 30 | 5. Supports interactive user input for selecting actions such as installing an application or adding a repository. 31 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #pyinstaller --onefile --icon ico.ico --noconsole main.py --name scoop-sd 2 | import requests 3 | import os 4 | from bs4 import BeautifulSoup as bs 5 | import re 6 | import argparse 7 | from prettytable import PrettyTable 8 | 9 | aparser = argparse.ArgumentParser() 10 | aparser.add_argument('search', nargs='?', default='') 11 | search = aparser.parse_args() 12 | def parser(): 13 | headers = { 14 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0', 15 | 'Accept': '*/*', 16 | 'Accept-Language': 'uk-UA,uk;q=0.8,en-US;q=0.5,en;q=0.3', 17 | 'Accept-Encoding': 'gzip, deflate, br', 18 | 'Referer': 'https://scoopsearch.github.io/', 19 | 'api-key': 'DC6D2BBE65FC7313F2C52BBD2B0286ED', 20 | 'Origin': 'https://scoopsearch.github.io', 21 | 'DNT': '1', 22 | 'Connection': 'keep-alive', 23 | 'Sec-Fetch-Dest': 'empty', 24 | 'Sec-Fetch-Mode': 'cors', 25 | 'Sec-Fetch-Site': 'cross-site', 26 | 'TE': 'trailers', 27 | } 28 | 29 | params = ( 30 | ('api-version', '2020-06-30'), 31 | ) 32 | 33 | json_data = { 34 | 'count': True, 35 | 'search': f'{search.search}', 36 | 'searchMode': 'all', 37 | 'filter': '', 38 | 'orderby': 'search.score() desc, Metadata/OfficialRepositoryNumber desc, NameSortable asc', 39 | 'skip': 0, 40 | 'top': 20, 41 | 'select': 'Id,Name,NamePartial,NameSuffix,Description,Homepage,License,Version,Metadata/Repository,Metadata/FilePath,Metadata/AuthorName,Metadata/OfficialRepository,Metadata/RepositoryStars,Metadata/Committed,Metadata/Sha', 42 | 'highlight': 'Name,NamePartial,NameSuffix,Description,Version,License,Metadata/Repository,Metadata/AuthorName', 43 | 'highlightPreTag': '', 44 | 'highlightPostTag': '', 45 | } 46 | 47 | r = requests.post('https://scoopsearch.search.windows.net/indexes/apps/docs/search', headers=headers, params=params, json=json_data) 48 | soup = bs(r.text, "lxml") 49 | #print(soup) 50 | pac_name = re.compile(r'"NameSuffix":"(.*?)"', re.MULTILINE | re.DOTALL) 51 | packets_names = soup.find_all(text=pac_name) 52 | pac_repository = re.compile(r'"Repository":"(.*?)"', re.MULTILINE | re.DOTALL) 53 | packets_repository = soup.find_all(text=pac_repository) 54 | table = PrettyTable() 55 | table.field_names = ['Number','App Name','Bucket'] 56 | array_app = [] 57 | array_bucket = [] 58 | i = -1 59 | for name in packets_names: 60 | i += 1 61 | i_number = f'{i})' 62 | rep_name = pac_repository.search(name.text).group(1).replace('/',' ').split()[-1] 63 | rep_url = pac_repository.search(name.text).group(1).replace('/',' ').replace(' ','/').split()[-1] 64 | bucket = f'scoop bucket add {rep_name} {rep_url}' 65 | app_name = pac_name.search(name.text).group(1) 66 | table.add_row([i_number, app_name, bucket]) 67 | array_bucket.append(bucket) 68 | array_app.append(app_name) 69 | print(table) 70 | func_select = input('To install the app, type \'i\'.\nTo add a repository, type \'b\'.\nTo exit, type \'q\'.\n(Select)>> ') 71 | if func_select == 'q': 72 | exit() 73 | if func_select == 'i': 74 | app_number = input('Select the application number to install.\n(Install_app)>> ') 75 | app_install = "scoop install " + array_app[int(app_number)] 76 | os.system(app_install) 77 | if func_select == 'b': 78 | bucket_number = input('Select the bucket number to add it.\n(Add_bucket)>> ') 79 | bucket_add = array_bucket[int(bucket_number)] 80 | os.system(bucket_add) 81 | parser() 82 | 83 | 84 | 85 | 86 | --------------------------------------------------------------------------------