├── requirements.txt ├── wallpaper.png ├── README.md ├── ConvertSrt2Per.py └── LICENSE /requirements.txt: -------------------------------------------------------------------------------- 1 | colorama==0.4.4 2 | googletrans==4.0.0rc1 3 | 4 | -------------------------------------------------------------------------------- /wallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kiahamedi/ConvertSrt2Per/HEAD/wallpaper.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ConvertSrt2Per 2 | > Convert English subtitle to Persian subtitle 3 | 4 | [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) 5 | 6 | ![alt text](https://raw.githubusercontent.com/kiahamedi/ConvertSrt2Per/master/wallpaper.png) 7 | 8 | ## dependencies 9 | for first use install depencency from requirements with run this command: 10 | ``` 11 | pip install -r requirements.txt 12 | ``` 13 | 14 | list of dependencies: 15 | * googletrans 16 | * colorama 17 | 18 | ## Downloading 19 | ```bash 20 | $ git clone https://github.com/kiahamedi/ConvertSrt2Per.git 21 | $ cd ConvertSrt2Per/ 22 | $ python ConvertStr2Per.py input.srt out.srt 23 | ``` 24 | 25 | ## Install Manual 26 | ```bash 27 | $ cd /tmp 28 | $ git clone https://github.com/kiahamedi/ConvertSrt2Per.git 29 | $ cd ConvertSrt2Per/ 30 | $ mv ConvertSrt2Per.py convertSrt2Per 31 | $ chmod +x convertSrt2Per 32 | $ sudo cp convertSrt2Per /usr/local/bin/ 33 | $ convertStr2Per input.srt out.srt 34 | ``` 35 | 36 | ## Install Auto 37 | `cd /tmp && git clone https://github.com/kiahamedi/ConvertSrt2Per.git && cd ConvertSrt2Per && mv ConvertSrt2Per.py convertSrt2Per && chmod +x convertSrt2Per && sudo cp convertSrt2Per /usr/local/bin/`
38 |
39 | now use this command for run:
40 | `convertStr2Per input.srt out.srt`
41 | 42 | ## Uninstall 43 | use this command for uninstall:
44 | `sudo rm /usr/local/bin/convertSrt2Per`
45 | 46 | ## warning 47 | >this script work with python 3 48 | 49 | 50 | ## Are you a developer? 51 | > 1-Fork it!
52 | > 2-Create your feature branch: git checkout -b my-new-feature
53 | > 3-Commit your changes: git commit -am 'Add some feature'
54 | > 4-Push to the branch: git push origin my-new-feature
55 | > 5-Submit a pull request
56 | -------------------------------------------------------------------------------- /ConvertSrt2Per.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # kia hamedi 3 | # www.kiahamedi.ir 4 | #kia.arta9793@gmail.com 5 | 6 | import sys 7 | from sys import platform 8 | from os import system 9 | from importlib import reload 10 | from googletrans import Translator 11 | from colorama import Fore 12 | 13 | reload(sys) 14 | 15 | translator = Translator() 16 | try: 17 | input_file_name = sys.argv[1] 18 | output_file_name = sys.argv[2] 19 | except Exception: 20 | print(f'{Fore.RED}Could Not Parse Arguments!\nUsage: python3 ConvertStr2Per.py input.srt output.srt') 21 | exit() 22 | number_of_lines = 0 23 | translated_lines = 0 24 | 25 | print('--------------------------------------------------') 26 | 27 | if platform == "linux" or platform == "linux2": 28 | print("Total Lines:") 29 | system("cat {} | wc -l ".format(input_file_name.replace(' ','\ '))) 30 | 31 | f_out = open(output_file_name, 'w') 32 | with open(input_file_name) as f_in: 33 | lines = f_in.readlines() 34 | 35 | for line in lines: 36 | number_of_lines += 1 37 | print("> Line of: " + str(number_of_lines)) 38 | if line.isdigit() and len(line) < 4: 39 | f_out.write(line) 40 | continue 41 | 42 | if line.startswith('0'): 43 | f_out.write(line) 44 | continue 45 | 46 | if line.startswith('