Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7536091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:28:51+00:00 2026-05-30T06:28:51+00:00

I was writing this small script the other day.It is a small program which

  • 0

I was writing this small script the other day.It is a small program which basically finds the flash videos running in the browser and downloads them.
the code goes something like this..

code:

path=$(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/lash/{print$2}')
pid=$(echo $path | cut -d / -f3)
name=$( ps --no-header -o comm -p $pid)
mid=$(wmctrl -l | grep -i $name)
filename=`echo $mid | cut -c 21-$(($(echo $mid | wc -c)-16))`
cp $path /home/Downloads/"$filename.avi"

this is just a PART of the code.The first line of the code gets the path to the deleted temp file.The second line gets the pid. Third the process name.Fourth the window id and the window title.The fifth line manipulates the wmctrl output to extract the name of the video playing(most of the time the name of the video is included in the window title..for example youtube)

Now when this script is run after the whole video has buffered,it runs flawlessly(this above script works for google chrome)..and copies the file from the /proc//fd folder to the downloads folder and changes its name to the extracted filename.

Now here comes the trick part.I want to automate this code,like,for me to run this code as of now i have to wait for the video to finish buffering(say youtube).

I want this script to determine when the video has finished buffering and then go ahead with the copying part without me having to manually run it at the end of a video.

So is there any way in which i can get to know when a video has completed buffering?

I am a beginner.Any suggestions for improving the code are welcome

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:28:52+00:00Added an answer on May 30, 2026 at 6:28 am

    to get the file size, you can use:

    stat -c %s $filename
    

    with this you can set up a while loop to check if the file is still changing

    CURSIZE=0
    LASTSIZE=1
    while ([ $CURSIZE -ne $LASTSIZE ]) do
      LASTSIZE=`stat -c %s $filename`
      sleep 1
    CURSIZE=`stat -c %s $filename`
    done
    

    after that, you should be able to copy it assuming your internet connection doesn’t hiccup for greater than the sleep value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a small script using pygame, but I don't believe this question
I am writing this java program to find all the prime numbers up to
I'm writing this question with reference to this one which I wrote yesterday. After
I'm writing this script to rotate a background Image every 3 seconds but it
I am writing a small script to be ran in a dialog when it
i'm writing a small script to tweet messages from the monitoring systems. The only
I am writing small process monitor script in Perl by reading values from Proc
I am in the process of writing a small(er) Python script to automate a
I'm writing a small script to capture link clicks and save the link's URL
I am writing a small script to test if a form has been altered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.