Python Coder for Video Player Improvement

Job ID: 38070117

Budget: ₹600 – ₹1,500 INR

Write python and Arduino code for this arduino_port = 'COM5' arduino_baudrate = 11520
During a channel broadcast, the Arduino D7,D8 relay should be turned on every 20 minutes 1 sec before playing ads.

Once theArduino D7,D8 relay on, ads need to be played. The ads folders are stored in the folder of 'C:\Users\KALAVANI\Downloads\Video' and should be played in VLC media player at full screen using the following Python code:

```python
import subprocess

def play_video(video_path):
vlc_path = r"C:\Program Files\VideoLAN\VLC\vlc.exe"
subprocess.Popen([vlc_path, '--fullscreen', video_path])
```

After the ads finish, the Arduino D7,D8 relay should be turned off and the normal broadcast can continue. Ads should be run on a priority basis. The folder named 'C:\Users\KALAVANI\Downloads\Video\1' is considered high priority and should be played three times an hour. The folder named 'C:\Users\KALAVANI\Downloads\Video\2' is medium priority and should be played twice an hour. The folder named 'C:\Users\KALAVANI\Downloads\Video\3' is low priority and should be played once an hour. Videos should be picked randomly from each folder, but every video should be played according to the priority basis mentioned above.

The maximum duration for an ad is upto 4 minutes. Once the ad starts to play, a message stating "ads start with ad name" needs to be sent via WhatsApp using the following API document:

```
secret = "f6684d2d330d8472cbd096329b7b2c03936ce85b"
account = "1714015555c4ca4238a0b923820dcc509a6f75849b6629cd43745da"
recipient = "+917868002606"
type: "text"
WhatsApp - Send Single Chat
Send a single chat message. Requires "wa_send" API permission.

POST https://plugsms.com/api/send/whatsapp
Parameter
Field Type Description
secret String
The API secret you copied from (Tools -> API Keys) page

account String
WhatsApp account you want to use for sending, you can get the account unique ID from /get/wa.accounts or in the dashboard.

recipient String
Recipient mobile number or group address, it will accept whatsapp group address or E.164 formatted number and locally formatted numbers using the country code from your profile settings.
Example for Philippines
E.164: +639184661533
Local: 09184661533

type (optional) String
Type of WhatsApp message.

Default value: text

Allowed values: "text", "media", "document"

message String
Message or caption you want to send, spintax is also supported.

priority (optional) Number
If you want to send the message as priority, it will be sent immediately. 1 for yes and 2 for no.

Default value: 2

media_file (optional) File
This is for "media" and "button" type message only. The media file you want to attach in the WhatsApp message, it supports jpg, png, gif, mp4, mp3 and ogg files. Please use POST method if you are using this parameter.

media_url (optional) String
This is for "media" and "button" type message only. The media file url, please use direct link to the media file. It will be downloaded and be attached in the WhatsApp message, it also supports jpg, png, gif, mp4, mp3, and ogg files. You can use GET method for this.

media_type (optional) String
This is for "media" type message only. You only need to enter this parameter if you are using "media_url" instead of "media_file". You need to declare the file type of the media in the url you provided.

Allowed values: "image", "audio", "video"

document_file (optional) File
This is for "document" type message only. The document file you want to attach in the WhatsApp message, it supports pdf, xls, xlsx, doc and docx files. Please use POST method if you are using this parameter.

document_url (optional) String
This is for "document" type message only. The document file url, please use direct link to the document file. It will be downloaded and be attached in the WhatsApp message, it also supports pdf, xls, xlsx, doc, and docx files. You can use GET method for this.

document_name (optional) String
This is for "document" type with "document_url" message only. The document file name, please include the file extension. For example: document.pdf

document_type (optional) String
This is for "document" type message only. You only need to enter this parameter if you are using "document_url" instead of "document_file". You need to declare the file type of the document in the url you provided.

Allowed values: "pdf", "xls", "xlsx", "doc", "docx"

shortener (optional) Number
Shortener ID, specify the shortener you want to use if you want to shorten the links in your message. You can get the list of available shorteners from /get/shorteners

Default value: none

Success Response Format
Field Type Description
status Number
List of Codes
200 = Success

message String
Response message

data Array
Array of data

Error Response Format
Name Type Description
status Number
List of Codes
400 = Invalid parameters
401 = Invalid API secret
403 = Access denied
404 = WhatsApp account doesn't exist
500 = Something went wrong

message String
Response message

data Array
Array of data

Send a Sample Request

url
https://plugsms.com/api/send/whatsapp
Parameters
secret
secret
String
account
account
String
recipient
recipient
String
type
type
String
message
message
String
priority
priority
Number
media_file
media_file
File
media_url
media_url
String
media_type
media_type
String
document_file
document_file
File
document_url
document_url
String
document_name
document_name
String
document_type
document_type
String
shortener
shortener
Number
PHP Example
Python Example
<?php

$chat = [
"secret" => "API_SECRET", // your API secret from (Tools -> API Keys) page
"account" => "90cf7d40a467d5f40a39fca222c216449cb9abee73e5e2b0b321060c2ae06a8fa9e45486",
"recipient" => "+918123456789",
"type" => "text",
"message" => "Hello World!"
];

$cURL = curl_init("https://plugsms.com/api/send/whatsapp");
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_POSTFIELDS, $chat);
$response = curl_exec($cURL);
curl_close($cURL);

$result = json_decode($response, true);

// do something with response
print_r($result);
Success Response
{
"status": 200,
"message": "WhatsApp message has been queued for sending!",
"data": false
}
Error Response
{
"status": 400,
"message": "Invalid Parameters!",
"data": false
}
WhatsApp - Start WhatsApp Campaign
Start WhatsApp Campaign. Requires "start_wa_campaign" API permission.

GET https://plugsms.com/api/remote/start.chats
Parameter
Field Type Description
secret String
The API secret you copied from (Tools -> API Keys) page

campaign Number
Campaign ID

Success Response Format
Field Type Description
status Number
List of Codes
200 = Success

message String
Response message

data Array
Array of data

Error Response Format
Name Type Description
status Number
List of Codes
400 = Invalid parameters
401 = Invalid API secret
403 = Access denied
404 = Device doesn't exist
500 = Something went wrong

message String
Response message

data Array
Array of data

Send a Sample Request

url
https://plugsms.com/api/remote/start.chats
Parameters
secret
secret
String
campaign
campaign
Number
PHP Example
Python Example
<?php

$apiSecret = "API_SECRET"; // your API secret from (Tools -> API Keys) page
$campaignId = 1;

$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, "https://plugsms.com/api/remote/start.chats?secret={$apiSecret}&campaign={$campaignId}");
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($cURL);
curl_close($cURL);

$result = json_decode($response, true);

// do something with response
print_r($result);
Success Response
{
"status": 200,
"message": "WhatsApp campaign has been resumed!",
"data": false
}
Error Response
{
"status": 400,
"message": "Invalid Parameters!",
"data": false
}"
```

After the ad finishes, the normal broadcast can continue. To monitor errors, create a separate error log with timestamps. Any errors can be monitored at this location: 'C:\Users\KALAVANI\Desktop\abi-py'.

For monitoring played video ads, create a separate video ads log that includes the video name, the number of times it's played, and the date and time that the video was played. Store this data in 'C:\Users\KALAVANI\Desktop\abi-py'.